3e6377b24eQqYMsDi9XrFkIgTzZ47A tools/balloon/Makefile
3e6377d6eiFjF1hHIS6JEIOFk62xSA tools/balloon/README
3e6377dbGcgnisKw16DPCaND7oGO3Q tools/balloon/balloon.c
-3eb781edFwm_pW9FwnQACIe68viLOw tools/control/Makefile
-3eb781fceEYkUi1XHKf2V0KX7si2JA tools/control/build-cmdline.xml
-3ec41f7cWCxQ8pdH8ZWqhhv-38qQ1w tools/control/build-web.xml
-3ec41f7ca6IBXDSe0HVcMPp3PPloOQ tools/control/build.properties
-3f0d61da3O5gkcntbIOdUmN2-RcZbQ tools/control/doc/INSTALL-cmdline
-3eca6a96a31IwaKtkEa4jmzwTWlm8Q tools/control/doc/INSTALL-web
-3f0d61daCTHGCpQK0Brz3PAp80d_2Q tools/control/doc/USAGE-cmdline
-3f77f25c4zdCalc5d0YnMGEnc9By-Q tools/control/examples/etc.exports-example
-3f776bd12y6bW-wtcs6rD2qhdpT_Rw tools/control/examples/grub.conf-example
-3f776bd1RBu7Gnce6Bq9328QFUZBsw tools/control/examples/xen-mynewdom
-3eb781fcabCKRogwxJA3-jJKstw9Vg tools/control/examples/xenctl.xml
-3f776bd1bfwM-pP6b2qd0vih1KeV8w tools/control/examples/xenctl.xml-dom0nfs
-3f776bd1-A4vvCCsz-KOgZyAj4ux2g tools/control/examples/xenctl.xml-linklocal
-3f776bd2y1sfPGpfiaj4A-sRdUON7A tools/control/examples/xenctl.xml-publicip
-3f042c35FzVap5QW0UBPnZ2ZM0l3QA tools/control/src/org/xenoserver/cmdline/CommandParser.java
-3eb781fdNQvEJW3tNvovjqoN7GlePA tools/control/src/org/xenoserver/cmdline/Main.java
-3f042c35-TPgpCQViIaJzLts2-CnBw tools/control/src/org/xenoserver/cmdline/ParseDomainDestroy.java
-3f042c35h9GAWRu7wimPjBpCi09nUA tools/control/src/org/xenoserver/cmdline/ParseDomainList.java
-3f042c359mRNaxBYXFwVsmv5-J_DJA tools/control/src/org/xenoserver/cmdline/ParseDomainNew.java
-3f042c35bMvqLB4Yc-0Dxs4WlYHHpw tools/control/src/org/xenoserver/cmdline/ParseDomainStart.java
-3f042c35Lc-JegNavF6Bj6coM486Ig tools/control/src/org/xenoserver/cmdline/ParseDomainStop.java
-3f042c35UhRkvblwKSx0KW2QHUn3Fw tools/control/src/org/xenoserver/cmdline/ParseFailedException.java
-3f0445524oTSyogDGmCAyKMM665Rxg tools/control/src/org/xenoserver/cmdline/ParseGroup.java
-3f042c35Inw0LzkOzXo9ncbEHZzUHA tools/control/src/org/xenoserver/cmdline/ParseHelp.java
-3f098761jTSCT4f7lCWFePC3TJN_nw tools/control/src/org/xenoserver/cmdline/ParsePartitionsAdd.java
-3f05631djnPcaqmzMFSa8RLmGCZ-0Q tools/control/src/org/xenoserver/cmdline/ParsePartitionsList.java
-3f05631dswxJX_TpcuG6tBstyHSetg tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java
-3f05631dMY7PMkwSY7zBFelGJ8goVg tools/control/src/org/xenoserver/cmdline/ParsePhysicalList.java
-3f05631dYDFXv6mwNFAgz3ta9kShJA tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java
-3f5f3d95BlaPZ2JHfpjHuHscx2SJow tools/control/src/org/xenoserver/cmdline/ParseScript.java
-3f0bdfabfXM4tMbvmV06di5U-5FfqA tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java
-3f0bec93F_VDIcn9oeXwJYwydX20kg tools/control/src/org/xenoserver/cmdline/ParseVbdShow.java
-3f098761TRsbDk9woUM846Q6_F7EmA tools/control/src/org/xenoserver/cmdline/ParseVdCreate.java
-3f099009pmH9MFkRYwP2V1DfsqEwdg tools/control/src/org/xenoserver/cmdline/ParseVdDelete.java
-3f098761zh9WTV6LpRqcet3gqlXdtg tools/control/src/org/xenoserver/cmdline/ParseVdFree.java
-3f099009lDK_5xXO4gPyPpCTUhgnCA tools/control/src/org/xenoserver/cmdline/ParseVdRefresh.java
-3f098761vY4hzt_QKskmvMcibN0zYQ tools/control/src/org/xenoserver/cmdline/ParseVdShow.java
-3f042c35V-Bf3dlIe1r5mZs8ZTPSvA tools/control/src/org/xenoserver/control/Command.java
-3f042c35U_4O2eovLKUgo2avPPHKUw tools/control/src/org/xenoserver/control/CommandDomainDestroy.java
-3f042c3570VRwuzl94tEozOIVBycNg tools/control/src/org/xenoserver/control/CommandDomainList.java
-3f042c35xVm-ucJAVdvC3acD6ZEe2Q tools/control/src/org/xenoserver/control/CommandDomainNew.java
-3f042c36GqoXJJj_BvWGwBeKwEzgvg tools/control/src/org/xenoserver/control/CommandDomainStart.java
-3f042c36bmZJD0xrxURD075avUlIUg tools/control/src/org/xenoserver/control/CommandDomainStop.java
-3f042c35hdwL__Airzyz4HutOgGRqQ tools/control/src/org/xenoserver/control/CommandFailedException.java
-3f0987611uZwg-o64yi0p_2aXCYEug tools/control/src/org/xenoserver/control/CommandPartitionAdd.java
-3f05631ev3UK5FRi5vgR08zDp3OZYw tools/control/src/org/xenoserver/control/CommandPhysicalGrant.java
-3f05631e_G6wzHhEnpihX0pIkEsbMw tools/control/src/org/xenoserver/control/CommandPhysicalList.java
-3f05631eGWxq7bojQbMa-tGxsENIhw tools/control/src/org/xenoserver/control/CommandPhysicalRevoke.java
-3f0bdfab88VYiD26FXCDmmAAGJ8zWA tools/control/src/org/xenoserver/control/CommandVbdCreate.java
-3f0bdfabI14M5_odjCIwQbXCdauReA tools/control/src/org/xenoserver/control/CommandVbdCreatePhysical.java
-3f0d4a70B132OMLyoUBFJAfNCATCww tools/control/src/org/xenoserver/control/CommandVbdList.java
-3f098761c5-idlmf9vWEMOlDw0VCHg tools/control/src/org/xenoserver/control/CommandVdCreate.java
-3f0990096KcyQw77qJmjTu941smS8A tools/control/src/org/xenoserver/control/CommandVdDelete.java
-3f0990093VJUL7QjxGigR5GPXf_Fkw tools/control/src/org/xenoserver/control/CommandVdRefresh.java
-3eb781fdBRXfSlWzK6GXlIQIlHFoaQ tools/control/src/org/xenoserver/control/Defaults.java
-3ec41f7cQ7Ug739JBDrsVH-7KJ5MvQ tools/control/src/org/xenoserver/control/Domain.java
-3ec41f7cAzdBu0lkuTTQx92rqSM9Qw tools/control/src/org/xenoserver/control/Extent.java
-3eb781fdDeZEopemXIVg_ARCGKSmBw tools/control/src/org/xenoserver/control/InetAddressPattern.java
-3ec41f7cqN_uVR_7TqjgypDfFdGyrg tools/control/src/org/xenoserver/control/Library.java
-3ec41f7dsb1R8BvBNzjYufMrx6ONdA tools/control/src/org/xenoserver/control/Mode.java
-3ec41f7dbqJLTy1msByMzQhy3jHHyQ tools/control/src/org/xenoserver/control/Partition.java
-3ec41f7djIGkw6M9meq8-YZ1WDATcw tools/control/src/org/xenoserver/control/PartitionManager.java
-3eb781fdmMkFbyb2SAGR0vsuFtl9Lw tools/control/src/org/xenoserver/control/Settings.java
-3eb781fdpgi83RpUvQWVccWjsDJK7w tools/control/src/org/xenoserver/control/StringPattern.java
-3ec41f7dNJZ1YkLD8X5CsqqYmP601g tools/control/src/org/xenoserver/control/VirtualBlockDevice.java
-3ec41f7dVFBlviwXPQ06BlU3UybziA tools/control/src/org/xenoserver/control/VirtualDisk.java
-3ec41f7dKX9YpwrfH7BZ7BogyWqqLA tools/control/src/org/xenoserver/control/VirtualDiskManager.java
-3ec41f7dUPpYTwYL5QVpRBv6PLKPrg tools/control/src/org/xenoserver/control/XML.java
-3ec41f7d7Try-2zmfnpaALwJjY0GCA tools/control/src/org/xenoserver/control/XMLHelper.java
-3ec41f7dOVZgjP4sQS6vjuBnExdlMQ tools/control/src/org/xenoserver/web/RootBean.java
-3ec41f7dvPdszb0frNEkMnEdJUBVjA tools/control/src/org/xenoserver/web/SystemConfigurationBean.java
-3ec41f7dO6IuKGGLG4VRUhMDmkTn5g tools/control/web/WEB-INF/web.xml
-3ec41f7dRAPXBA0jQUd1k6MB3xVidg tools/control/web/img/cambridge.gif
-3ec41f7dvxVe1Vb3kVOLZcN5Jra2tQ tools/control/web/img/help.gif
-3ec41f7dJYExm-ityN2SgVVaeR_BYA tools/control/web/img/home.gif
-3ec41f7d4IYjCuVYWjgq-OCue4O0Vw tools/control/web/img/pixel.gif
-3ec41f7dW6Rxbc2h5vulWqEkj0rMzA tools/control/web/img/search.gif
-3ec41f7d-WawzXt-iMiQON6VVF0d6Q tools/control/web/img/xeno.gif
-3ec41f7d6gAIVIeI6d36osnxPNIbEw tools/control/web/tmpl/about.tmpl
-3ec41f7dU7BdfMqTjNuI2yFIE9YTxQ tools/control/web/tmpl/dom-del.tmpl
-3ec41f7dnAVr1lPsPDV0cwNe-cDiSw tools/control/web/tmpl/dom-delr.tmpl
-3ec41f7dKNiNO7usbqUVaXvZafVzSg tools/control/web/tmpl/dom-lis.tmpl
-3ec41f7dJ4oF7TdF8c858DgzXAPJUA tools/control/web/tmpl/dom-new.tmpl
-3ec41f7dPelejfeiuXzFeETZXtYY3g tools/control/web/tmpl/dom-newr.tmpl
-3ec41f7deN7cXpkmKhmp9nGMWtQ9Yw tools/control/web/tmpl/dom-sta.tmpl
-3ec41f7dFl7cFsLVTEu06abaLjrh7A tools/control/web/tmpl/dom-star.tmpl
-3ec41f7dOyejg7nsGjHhwS9dRwuwJQ tools/control/web/tmpl/dom-stp.tmpl
-3ec41f7d-jdCAs49yO8mmvGdbVnFcQ tools/control/web/tmpl/dom-stpr.tmpl
-3ec41f7d2S1JM6utrcajiWWmPi85TA tools/control/web/tmpl/dom.tmpl
-3ec41f7dPyCkHbXAufQ0Nxnvhq7XpQ tools/control/web/tmpl/dommenu.tmpl
-3ec41f7dZRDqKe8wk__95ztDQmaAOA tools/control/web/tmpl/help.tmpl
-3ec41f7eTqbaFqMGU7lJG09vlEt0TQ tools/control/web/tmpl/index.tmpl
-3ec41f7ed6_QZ1mg0vuA9Xu1wu1plw tools/control/web/tmpl/install.pl
-3ec41f7emmAnjM4gsW6JWkqsjfi4Rg tools/control/web/tmpl/makefile
-3f0d3c5bP8omJUhjEmXpsRvOZH3igw tools/control/web/tmpl/pd-g.tmpl
-3f0d3c5bpmNu22iZ8mb-9hzOZUWEZw tools/control/web/tmpl/pd-gr.tmpl
-3f0d3c5b1oQA8A-Y4AK0akN9k2T1KQ tools/control/web/tmpl/pd-l.tmpl
-3f0d3c5bkJgUEumHh-qAL3ZB1xApSw tools/control/web/tmpl/pd-r.tmpl
-3f0d3c5bOEOuHzB1HdWY9GvlYj7H-w tools/control/web/tmpl/pd-rr.tmpl
-3f0d3c5cb9-AClRfExuRwJi45LcYuA tools/control/web/tmpl/pd.tmpl
-3f0d3c5cQqQ23OpQJx-sNE0-EclRlA tools/control/web/tmpl/pdmenu.tmpl
-3ec41f7eoDHD2raa4x6dBINr4QLO3A tools/control/web/tmpl/vd-fv.tmpl
-3ec41f7eawycxV05Ow3LfZtOlHZJPA tools/control/web/tmpl/vd-pa.tmpl
-3ec41f7ef4mVT4vwOEL40MKIzS4EeA tools/control/web/tmpl/vd-par.tmpl
-3ec41f7e1-bFRAfSveBhJNc-yQguXQ tools/control/web/tmpl/vd-pv.tmpl
-3ec41f7e6v7MAKuV03qkOLX94vCGQg tools/control/web/tmpl/vd-vbdc.tmpl
-3ec41f7eInaxQyoN0zPtGH6O1l0qaA tools/control/web/tmpl/vd-vbdcr.tmpl
-3ec41f7eSe6rb0p4IxLU16czqIaTCA tools/control/web/tmpl/vd-vbdv.tmpl
-3ec41f7eAYtNdK1Yy-RdGMCcSDNfBA tools/control/web/tmpl/vd-vdc.tmpl
-3ec41f7eFxwTmuQ8wWMdvVQ5jtiKKA tools/control/web/tmpl/vd-vdcr.tmpl
-3ec41f7e2osvqR4HUXCd9zUIIvUjaA tools/control/web/tmpl/vd-vdd.tmpl
-3ec41f7e_TlFUNtMUUk1vivYx-4M2w tools/control/web/tmpl/vd-vddr.tmpl
-3ec41f7eqey0GnU2CvlvO0OvX0Pmgg tools/control/web/tmpl/vd-vdr.tmpl
-3ec41f7elad0gJQYmWPOikqUUKkMtA tools/control/web/tmpl/vd-vdrr.tmpl
-3ec41f7eQ2vdTzXZAbxIWCosxZHJkg tools/control/web/tmpl/vd-vdv.tmpl
-3ec41f7estxrL28BGG8obBnzt-SiAA tools/control/web/tmpl/vd.tmpl
-3ec41f7e6SAwV8ebs9Be7zV2LV92oQ tools/control/web/tmpl/vdmenu.tmpl
-3ec41f7ecn3uvsSrOVxKC8G8ACuulg tools/control/web/tmpl/xenofoot.def
-3ec41f7ek1RffqN2yRUzSTkD5m1J6w tools/control/web/tmpl/xenohead.def
-3ec41f7e1ZpfCsgQ2qRJBooBn_iRtA tools/control/web/tmpl/xenostyle.css
-3eb781fc6vgq5yhkJRGDLY9gWWRY2A tools/control/xenctl
-3eb781fdl4lXWYZzmqDDUAYhAThRqQ tools/internal/Makefile
-3eb781fdc539MQQm47rYRCCR3N5i-Q tools/internal/dom0_defs.h
-3eb781fdKiQbgozBsgs_zzJQ9ubehw tools/internal/mem_defs.h
-3ec61e1bJCeJJu0SsptmDpA1xKvwvw tools/internal/rpm.spec
-3eb781fdgbSkh2O6JQS-65Dz4n0ItQ tools/internal/xi_build.c
-3eb781fdW1SAyiaC4mTsXq_9fRHh-A tools/internal/xi_create.c
-3eb781fdcJ0fF7rWfzAOArW-x4-gwA tools/internal/xi_destroy.c
-3ec43c5dmQxGDvgJJXbV1yLxT30Y1A tools/internal/xi_helper
-3f108ad5wQm0ZaQ4GXFoUhH1W1aW9w tools/internal/xi_list.c
-3f0458aaXhD8BQAggO81gv30RQ-ifA tools/internal/xi_phys_grant.c
-3fb14ab76b0aJu66S18CVjlemLwk4Q tools/internal/xi_read_console_ring.c
-3fa9861aBdNV1yCjfY4cLPr4Mtrpuw tools/internal/xi_restore_linux.c
-3fa98615LWZfagwDBp7XfuC-u9wi3w tools/internal/xi_save_linux.c
-3f108adb2b5OkKL6-faG3lMiOYDf_w tools/internal/xi_sched_domain.c
-3f108ade1v8weyh1sKx890VTd240Hw tools/internal/xi_sched_global.c
-3eb781fd8oRfPgH7qTh7xvgmwD6NgA tools/internal/xi_start.c
-3eb781fd0Eo9K1jEFCSAVzO51i_ngg tools/internal/xi_stop.c
-3f108ae2to5nHRRXfvUK7oxgjcW_yA tools/internal/xi_usage.c
-3fb01fd5CGkDlZddcIlPxLwrquLqKA tools/internal/xi_vbd_add.c
-3fb01fd5MoGCWdylPicf4UinUjYfDg tools/internal/xi_vbd_create.c
-3fb01fd54I4P44vZDb1CtDt1BytDtA tools/internal/xi_vbd_info.c
-3fb01fd5B-UeibZkmSCOUZckNyNFYA tools/internal/xi_vbd_list.c
-3f86be322bd0h9jG3krZFOUgCDoxZg tools/internal/xi_vif_params.c
-3eb781fd7211MZsLxJSiuy7W4KnJXg tools/internal/xi_vifinit
3f776bd2Xd-dUcPKlPN2vG89VGtfvQ tools/misc/Makefile
3f6dc136ZKOjd8PIqLbFBl_v-rnkGg tools/misc/miniterm/Makefile
3f6dc140C8tAeBfroAF24VrmCS4v_w tools/misc/miniterm/README
3f13d81e6Z6806ihYYUw8GVKNkYnuw tools/misc/xen_nat_enable.README
3f1668d4F29Jsw0aC0bJEIkOBiagiQ tools/misc/xen_read_console.c
3f87ba90EUVPQLVOlFG0sW89BCwouQ tools/misc/xen_refresh_dev.c
+3fbe2f12OPAkzIUtumU3wRAihnhocQ tools/misc/xi_createlinuxdom.py
+3fbe2f12dZbmXLlgQdMgkmnSUj23AQ tools/misc/xi_destroydom.py
+3fbe2f12ltvweb13kBSsxqzZDAq4sg tools/misc/xi_listdoms.py
+3fbe2f12Bnt8mwmr1ZCP6HWGS6yvYw tools/misc/xi_stopdom.py
3fbca441SjQr8vJwTQIgH1laysaWog tools/xc/Makefile
3fbba6dbDfYvJSsw9500b4SZyUhxjQ tools/xc/lib/Makefile
3fbba6dbEVkVMX0JuDFzap9jeaucGA tools/xc/lib/libxc_bvtsched.c
3e6377f5xwPfYZkPHPrDbEq1PRN7uQ xenolinux-2.4.22-sparse/arch/xeno/drivers/balloon/Makefile
3e6377f8Me8IqtvEhb70XFgOvqQH7A xenolinux-2.4.22-sparse/arch/xeno/drivers/balloon/balloon.c
3e5a4e65iHEuC5sjFhj42XALYbLVRw xenolinux-2.4.22-sparse/arch/xeno/drivers/block/Makefile
-3f689056Vxx_8K8DQTRysOxx_ikmLg xenolinux-2.4.22-sparse/arch/xeno/drivers/block/info.c
3e5a4e65pP5spJErBW69pJxSSdK9RA xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.c
3e67f822FOPwqHiaRKbrskgWgoNL5g xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.h
3e676eb5RXnHzSHgA1BvM0B1aIm4qg xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_vbd.c
Build the Domain Control Tools
==============================
-Under '/xeno-1.1.bk/tools', there are four sub-directories:
-'balloon', 'control', 'internal' and 'misc', each containing
+Under '/xeno-1.1.bk/tools', there are three sub-directories:
+'balloon', 'xc' and 'misc', each containing
a group of tools. You can enter any of the four sub-directories
and type 'make' to compile the corresponding group of tools.
Or you can type 'make' under '/xeno-1.1.bk/tools' to compile
all the tools.
-Particularly, in order to compile tools under 'control', you
-must have Apache Ant installed. Latest binary can be found at
-'http://ant.apache.org/bindownload.cgi'.
+In order to compile the control-interface library in 'xc' you must
+have zlib and devlopment headers installed. Also you will need at
+least Python v2.2.
-Besides, you must have Java J2SDK 1.4 installed. There seemed
-to be compilation errors with J2SDK 1.3, but fine with J2SDK 1.4
-
-To summarize:
-
-# cd /xeno-1.1.bk/tools
-# make
-# make install
-# cd /install/bin
-# cp * /usr/local/bin
+'make install' in the tools directory will place executables and
+libraries in an install directory immediately outside you local
+repository. NOTE: the installation of the Python modules may need root
+privileges if you are not using a personal installation of Python.
Installation
dom0_mem=xxx Set the maximum amount of memory for domain0.
-Xenctl Configuration
-==============================
-
-# cd /xeno-1.1.bk/tools/control/examples
-# cp xenctl.xml xen-mynewdom /etc
-
-Then, you need to modify /etc/xen-mynewdom:
-
-# cat /etc/xen-mynewdom
-domain new
-physical grant -pcdrom_link
-domain start
-
-You should substitue 'cdrom_link' with the
-root partition, e.g. '/dev/hda3', '/dev/sda1'.
-Therefore, the second looks like:
-'physical grant -p/dev/hda3'
-
-Then, you need to modify /etc/xenctl.xml:
-
-# cat /etc/xenctl.xml
-<?xml version="1.0"?>
-<domctl_defaults>
-<domain_name>XenoLinux</domain_name>
-<domain_size_kb>98304</domain_size_kb>
-<domain_image>/boot/xenolinux.gz</domain_image>
-<domain_vifs>1</domain_vifs>
-<domain_init_rd>/boot/initrd.gz</domain_init_rd>
-<root_device>/dev/ram0</root_device>
-<root_args>rw</root_args>
-<args>init=/linuxrc 4 DOMID=+</args>
-<nw_ip>169.254.1.0+</nw_ip>
-<nw_gw>169.254.1.0</nw_gw>
-<nw_mask>255.255.0.0</nw_mask>
-<nw_nfs_server>169.254.1.0</nw_nfs_server>
-<max_domain_number>1000</max_domain_number>
-<xi_tools_dir>/usr/local/bin/</xi_tools_dir>
-</domctl_defaults>
-
-The meaning of every line is very straightforward
-and should be modified according to your configuration.
-
-Normally you don't need <domain_init_rd>. And you probably want
-root_args set to "ro", otherwise fsck will complain. Assuming you've
-installed a standard linux installation, you probably don't want to
-explicit set the init program, or the run level,
-e.g. <args>DOMID=+</args>
-
-
Boot into Domain 0
==============================
by xen_read_console running in Domain 0 and output are printed out to
the standard output.
-# xenctl script -f/etc/xen-mynewdom
-
-This will create and start a new domain based on /etc/xen-mynewdom and
-/etc/xenctl.xml
+Now edit the installed xi_createlinuxdom.py script to your taste. This
+should then be executed as root to create a new domain.
You should be able to see XenoLinux boot message on standard output
-with each line prepended [domain_id].
+with each line prepended with [domain_id].
List and Stop Domains
==============================
You can see a list of existing domains with:
-
-# xi_list
-or
-# xenctl domain list
+# xi_listdoms.py
In order to stop a domain, you use:
+# xi_stopdom.py <domain_id>
+
+To destroy a domain use ('force' causes an immediate destruction
+without waiting for the guest OS to shut down cleanly):
+# xi_destroydom.py <domain_id> [force]
+
+
+Other Control Tasks using Python
+================================
+
+A Python module 'Xc' is installed as part of the tools-install
+process. This can be imported, and an 'xc object' instantiated, to
+provide access to privileged command operations:
+
+# import Xc
+# xc = Xc.new()
+# dir(xc)
+# help(xc.domain_create)
+
+In this way you can see that the class 'xc' contains useful
+documentation for you to consult.
-# xi_stop domain_id
-or
-# xenctl domain stop -ndomain_id
+A further module of useful routines (XenoUtil) is also installed:
-followed by
-# xi_destroy domain_id
-or
-# xenctl domain destroy -ndomain_id
\ No newline at end of file
+# import XenoUtil
+# help(XenoUtil)
\ No newline at end of file
all:
$(MAKE) -C balloon
- $(MAKE) -C control
- $(MAKE) -C internal
$(MAKE) -C xc
$(MAKE) -C misc
install: all
$(MAKE) -C balloon install
- $(MAKE) -C control install
- $(MAKE) -C internal install
$(MAKE) -C xc install
$(MAKE) -C misc install
clean:
$(MAKE) -C balloon clean
- $(MAKE) -C control clean
- $(MAKE) -C internal clean
$(MAKE) -C xc clean
$(MAKE) -C misc clean
+++ /dev/null
-#default: cmdline web
-default: cmdline
-
-#install: install-cmdline install-web
-install: install-cmdline examples
-
-clean: clean-cmdline clean-web
-
-examples: FORCE
- mkdir -p ../../../install/etc
- chmod +w ../../../install/etc/* || true
- cp examples/xen* examples/*example ../../../install/etc/
-
-cmdline: FORCE
- ant -buildfile build-cmdline.xml dist
-
-install-cmdline: cmdline
- mkdir -p ../../../install/bin
- cp -a xenctl-cmdline.jar xenctl ../../../install/bin
- chmod 755 ../../../install/bin/xenctl
-
-clean-cmdline:
- ant -buildfile build-cmdline.xml clean
- rm -f xenctl-cmdline.jar
-
-
-
-web: FORCE
- ant -buildfile build-web.xml dist
-
-install-web: xenctl
- ant -buildfile build-web.xml remove || true
- ant -buildfile build-web.xml install
-
-clean-web:
- ant -buildfile build-web.xml clean
- rm -f xenctl-web.jar
-
-FORCE:
+++ /dev/null
-<project name="xenctl cmdline project" default="compile">
- <property name="src" location="src"/>
- <property name="build" location="build-cmdline"/>
-
- <target name="init">
- <tstamp/>
- <mkdir dir="${build}"/>
- </target>
-
- <target name="compile" depends="init">
- <javac srcdir="${src}" destdir="${build}" debug="on">
- <include name="org/xenoserver/cmdline/**"/>
- <include name="org/xenoserver/control/**"/>
- </javac>
- </target>
-
- <target name="dist" depends="compile">
- <jar jarfile="xenctl-cmdline.jar"
- excludes="*~"
- basedir="${build}">
- <fileset dir="${src}">
- <include name="org/xenoserver/cmdline/**"/>
- <include name="org/xenoserver/control/**"/>
- </fileset>
- <fileset dir=".">
- <include name="build-cmdline.xml"/>
- <include name="xenctl"/>
- <include name="xenctl.xml"/>
- <include name="Makefile"/>
- </fileset>
- <manifest>
- <attribute name="Built-By" value="${user.name}"/>
- <attribute name="Main-Class" value="org.xenoserver.cmdline.Main"/>
- <attribute name="Sealed" value="true"/>
- </manifest>
- </jar>
- </target>
-
- <target name="test" depends="compile">
- <java fork="true" classname="org.xenoserver.cmdline.Main">
- <classpath>
- <pathelement path="${build}"/>
- </classpath>
- </java>
- </target>
-
- <target name="clean">
- <delete dir="${build}"/>
- </target>
-</project>
+++ /dev/null
-<!--
- General purpose build script for web applications and web services,
- including enhanced support for deploying directly to a Tomcat 4
- based server.
-
- This build script assumes that the source code of your web application
- is organized into the following subdirectories underneath the source
- code directory from which you execute the build script:
-
- docs Static documentation files to be copied to
- the "docs" subdirectory of your distribution.
-
- src Java source code (and associated resource files)
- to be compiled to the "WEB-INF/classes"
- subdirectory of your web applicaiton.
-
- web Static HTML, JSP, and other content (such as
- image files), including the WEB-INF subdirectory
- and its configuration file contents.
-
- $Id: build.xml.txt,v 1.7 2002/12/28 09:08:58 jfclere Exp $
--->
-
-
-<!-- A "project" describes a set of targets that may be requested
- when Ant is executed. The "default" attribute defines the
- target which is executed if no specific target is requested,
- and the "basedir" attribute defines the current working directory
- from which Ant executes the requested task. This is normally
- set to the current working directory.
--->
-
-<project name="xenctl web interface" default="compile" basedir=".">
-
-
-
-<!-- ===================== Property Definitions =========================== -->
-
-
-<!--
-
- Each of the following properties are used in the build script.
- Values for these properties are set by the first place they are
- defined, from the following list:
-
- * Definitions on the "ant" command line (ant -Dfoo=bar compile).
-
- * Definitions from a "build.properties" file in the top level
- source directory of this application.
-
- * Definitions from a "build.properties" file in the developer's
- home directory.
-
- * Default definitions in this build.xml file.
-
- You will note below that property values can be composed based on the
- contents of previously defined properties. This is a powerful technique
- that helps you minimize the number of changes required when your development
- environment is modified. Note that property composition is allowed within
- "build.properties" files as well as in the "build.xml" script.
-
--->
-
- <property file="build.properties"/>
- <property file="${user.home}/build.properties"/>
-
-
-<!-- ==================== File and Directory Names ======================== -->
-
-
-<!--
-
- These properties generally define file and directory names (or paths) that
- affect where the build process stores its outputs.
-
- app.name Base name of this application, used to
- construct filenames and directories.
- Defaults to "myapp".
-
- app.path Context path to which this application should be
- deployed (defaults to "/" plus the value of the
- "app.name" property).
-
- app.version Version number of this iteration of the application.
-
- build.home The directory into which the "prepare" and
- "compile" targets will generate their output.
- Defaults to "build".
-
- catalina.home The directory in which you have installed
- a binary distribution of Tomcat 4. This will
- be used by the "deploy" target.
-
- dist.home The name of the base directory in which
- distribution files are created.
- Defaults to "dist".
-
- manager.password The login password of a user that is assigned the
- "manager" role (so that he or she can execute
- commands via the "/manager" web application)
-
- manager.url The URL of the "/manager" web application on the
- Tomcat installation to which we will deploy web
- applications and web services.
-
- manager.username The login username of a user that is assigned the
- "manager" role (so that he or she can execute
- commands via the "/manager" web application)
-
--->
-
- <property name="app.name" value="xenctl"/>
- <property name="app.path" value="/${app.name}"/>
- <property name="app.version" value="0.1-dev"/>
- <property name="build.home" value="${basedir}/build-web"/>
- <property name="catalina.home" value="../../../.."/> <!-- UPDATE THIS! -->
- <property name="dist.home" value="${basedir}/dist-web"/>
- <property name="src.home" value="${basedir}/src"/>
- <property name="web.home" value="${basedir}/web"/>
-
-
-<!-- ================== Custom Ant Task Definitions ======================= -->
-
-
-<!--
-
- These properties define custom tasks for the Ant build tool that interact
- with the "/manager" web application installed with Tomcat 4. Before they
- can be successfully utilized, you must perform the following steps:
-
- - Copy the file "server/lib/catalina-ant.jar" from your Tomcat 4
- installation into the "lib" directory of your Ant installation.
-
- - Create a "build.properties" file in your application's top-level
- source directory (or your user login home directory) that defines
- appropriate values for the "manager.password", "manager.url", and
- "manager.username" properties described above.
-
- For more information about the Manager web application, and the functionality
- of these tasks, see <http://localhost:8080/tomcat-docs/manager-howto.html>.
-
--->
-
- <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"/>
- <taskdef name="list" classname="org.apache.catalina.ant.ListTask"/>
- <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"/>
- <taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask"/>
-
-
-<!-- ==================== Compilation Control Options ==================== -->
-
-<!--
-
- These properties control option settings on the Javac compiler when it
- is invoked using the <javac> task.
-
- compile.debug Should compilation include the debug option?
-
- compile.deprecation Should compilation include the deprecation option?
-
- compile.optimize Should compilation include the optimize option?
-
--->
-
- <property name="compile.debug" value="true"/>
- <property name="compile.deprecation" value="false"/>
- <property name="compile.optimize" value="true"/>
-
-
-
-<!-- ==================== External Dependencies =========================== -->
-
-
-<!--
-
- Use property values to define the locations of external JAR files on which
- your application will depend. In general, these values will be used for
- two purposes:
- * Inclusion on the classpath that is passed to the Javac compiler
- * Being copied into the "/WEB-INF/lib" directory during execution
- of the "deploy" target.
-
- Because we will automatically include all of the Java classes that Tomcat 4
- exposes to web applications, we will not need to explicitly list any of those
- dependencies. You only need to worry about external dependencies for JAR
- files that you are going to include inside your "/WEB-INF/lib" directory.
-
--->
-
-<!-- Dummy external dependency -->
-<!--
- <property name="foo.jar"
- value="/path/to/foo.jar"/>
--->
-
-
-<!-- ==================== Compilation Classpath =========================== -->
-
-<!--
-
- Rather than relying on the CLASSPATH environment variable, Ant includes
- features that makes it easy to dynamically construct the classpath you
- need for each compilation. The example below constructs the compile
- classpath to include the servlet.jar file, as well as the other components
- that Tomcat makes available to web applications automatically, plus anything
- that you explicitly added.
-
--->
-
- <path id="compile.classpath">
-
- <!-- Include all JAR files that will be included in /WEB-INF/lib -->
- <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
-<!--
- <pathelement location="${foo.jar}"/>
--->
-
- <!-- Include all elements that Tomcat exposes to applications -->
- <pathelement location="${catalina.home}/common/classes"/>
- <fileset dir="${catalina.home}/common/endorsed">
- <include name="*.jar"/>
- </fileset>
- <fileset dir="${catalina.home}/common/lib">
- <include name="*.jar"/>
- </fileset>
- <pathelement location="${catalina.home}/shared/classes"/>
- <fileset dir="${catalina.home}/shared/lib">
- <include name="*.jar"/>
- </fileset>
-
- </path>
-
-
-
-<!-- ==================== All Target ====================================== -->
-
-<!--
-
- The "all" target is a shortcut for running the "clean" target followed
- by the "compile" target, to force a complete recompile.
-
--->
-
- <target name="all" depends="clean,compile"
- description="Clean build and dist directories, then compile"/>
-
-
-
-<!-- ==================== Clean Target ==================================== -->
-
-<!--
-
- The "clean" target deletes any previous "build" and "dist" directory,
- so that you can be ensured the application can be built from scratch.
-
--->
-
- <target name="clean"
- description="Delete old build and dist directories">
- <delete dir="${build.home}"/>
- <delete dir="${dist.home}"/>
- <exec executable="make" dir="${web.home}/tmpl"><arg value="clean"/></exec>
- </target>
-
-
-
-<!-- ==================== Compile Target ================================== -->
-
-<!--
-
- The "compile" target transforms source files (from your "src" directory)
- into object files in the appropriate location in the build directory.
- This example assumes that you will be including your classes in an
- unpacked directory hierarchy under "/WEB-INF/classes".
-
--->
-
- <target name="compile" depends="prepare"
- description="Compile Java sources">
-
- <!-- Compile Java classes as necessary -->
- <mkdir dir="${build.home}/WEB-INF/classes"/>
- <javac srcdir="${src.home}"
- destdir="${build.home}/WEB-INF/classes"
- debug="${compile.debug}"
- deprecation="${compile.deprecation}"
- optimize="${compile.optimize}">
- <classpath refid="compile.classpath"/>
- <include name="org/xenoserver/control/**"/>
- <include name="org/xenoserver/web/**"/>
- </javac>
-
- <!-- Copy application resources -->
- <copy todir="${build.home}/WEB-INF/classes">
- <fileset dir="${src.home}" excludes="**/*.java"/>
- </copy>
-
- </target>
-
-
-
-<!-- ==================== Dist Target ===================================== -->
-
-
-<!--
-
- The "dist" target creates a binary distribution of your application
- in a directory structure ready to be archived in a tar.gz or zip file.
- Note that this target depends on:
-
- * "compile" so that the entire web application (including external
- dependencies) will have been assembled
-
--->
-
- <target name="dist" depends="compile"
- description="Create binary distribution">
-
- <!-- Create application JAR file -->
- <jar jarfile="${dist.home}/${app.name}-${app.version}.war"
- basedir="${build.home}"/>
-
- <!-- Copy additional files to ${dist.home} as necessary -->
-
- </target>
-
-
-
-<!-- ==================== Install Target ================================== -->
-
-<!--
-
- The "install" target tells the specified Tomcat 4 installation to dynamically
- install this web application and make it available for execution. It does
- *not* cause the existence of this web application to be remembered across
- Tomcat restarts; if you restart the server, you will need to re-install all
- this web application.
-
- If you have already installed this application, and simply want Tomcat to
- recognize that you have updated Java classes (or the web.xml file), use the
- "reload" target instead.
-
- NOTE: This target will only succeed if it is run from the same server that
- Tomcat is running on.
-
- NOTE: This is the logical opposite of the "remove" target.
-
--->
-
- <target name="install" depends="compile"
- description="Install application to servlet container">
-
- <install url="${manager.url}"
- username="${manager.username}"
- password="${manager.password}"
- path="${app.path}"
- war="file://${build.home}"/>
-
- </target>
-
-
-<!-- ====================== List Target =================================== -->
-
-<!--
-
- The "list" target asks the specified Tomcat 4 installation to list the
- currently running web applications, either loaded at startup time or
- installed dynamically. It is useful to determine whether or not the
- application you are currently developing has been installed.
-
--->
-
- <target name="list"
- description="List installed applications on servlet container">
-
- <list url="${manager.url}"
- username="${manager.username}"
- password="${manager.password}"/>
-
- </target>
-
-
-<!-- ==================== Prepare Target ================================== -->
-
-<!--
-
- The "prepare" target is used to create the "build" destination directory,
- and copy the static contents of your web application to it. If you need
- to copy static files from external dependencies, you can customize the
- contents of this task.
-
- Normally, this task is executed indirectly when needed.
-
--->
-
- <target name="prepare">
-
- <!-- Create build directories as needed -->
- <mkdir dir="${build.home}"/>
- <mkdir dir="${build.home}/WEB-INF"/>
- <mkdir dir="${build.home}/WEB-INF/classes"/>
- <mkdir dir="${dist.home}"/>
-
- <!-- create templates -->
- <exec executable="make" dir="${web.home}/tmpl"/>
-
- <!-- Copy static content of this web application -->
- <copy todir="${build.home}">
- <fileset dir="${web.home}"/>
- </copy>
-
- <!-- Copy external dependencies as required -->
- <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
- <mkdir dir="${build.home}/WEB-INF/lib"/>
-<!--
- <copy todir="${build.home}/WEB-INF/lib" file="${foo.jar}"/>
--->
-
- <!-- Copy static files from external dependencies as needed -->
- <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
-
- </target>
-
-
-<!-- ==================== Reload Target =================================== -->
-
-<!--
-
- The "reload" target tells the specified Tomcat 4 installation to dynamically
- reload this web application, to reflect changes in the underlying classes or
- the "web.xml" deployment descriptor.
-
--->
-
- <target name="reload" depends="compile"
- description="Reload application on servlet container">
-
- <reload url="${manager.url}"
- username="${manager.username}"
- password="${manager.password}"
- path="${app.path}"/>
-
- </target>
-
-
-<!-- ==================== Remove Target =================================== -->
-
-<!--
-
- The "remove" target tells the specified Tomcat 4 installation to dynamically
- remove this web application from service.
-
- NOTE: This is the logical opposite of the "install" target.
-
--->
-
- <target name="remove"
- description="Remove application on servlet container">
-
- <remove url="${manager.url}"
- username="${manager.username}"
- password="${manager.password}"
- path="${app.path}"/>
-
- </target>
-
-
- <target name="help">
- <echo>all clean, them compile</echo>
- <echo>dist create war file</echo>
- <echo>install install application in servlet container</echo>
- <echo>list list applications installed in servelet container</echo>
- <echo>reload reload application in servlet container</echo>
- <echo>remove dynamically remove web application</echo>
- </target>
-
-</project>
+++ /dev/null
-catalina.home=/usr/groups/xeno/build_tools/jakarta-tomcat-4.1.24
-# change <hostname> to your xenoserver
-manager.url=http://<hostname>/manager
-manager.username=hobbes
-manager.password=tiger
-compile.optimize=false
-
+++ /dev/null
-To install command line interface:
-
-cd xeno.bk/tools/control
-make cmdline
-cp xenctl xenctl-cmdline.jar <dom0>/usr/local/bin
-cp xenctl.xml <dom0>/etc
-mkdir <dom0>/var/lib/xen
-
-First invocation of command line interface will give a warning about not being
-able to load the disk state from /var/lib/xen/vdstate.xml. This is ok, it'll
-be created the first time you change any state in the virtual disk manager.
-
-If you already have /etc/domctl.xml you can rename it to xenctl.xml to keep
-your existing defaults.
+++ /dev/null
-
-some notes on configuring xenctl web interface...
-
-to build:
-
- export PATH=/usr/groups/xeno/build_tools/bin:${PATH}
- # this next step has already been done.
- # cp $CATALINA_HOME/server/lib/catalina-ant.jar $ANT_HOME/lib
- cd xeno.bk/tools/control
- make web
- # You only need to make/install internal if you haven't already
- # it's also needed by the cmdline tool
- cd xeno.bk/tools/internal
- make
-
-to setup:
-
- ## expand the jakarta (aka catalina) tree somewhere accessible by dom0
- export ROOTDIR=/anfs/scratch/<somewhere>
- cd $ROOTDIR
- tar zxf /usr/groups/xeno/archive/tomcat-4.1.24.tar.gz
- export CATALINA_HOME=$ROOTDIR/jakarta-tomcat-4.1.24
- export JAVA_HOME=/usr/groups/xeno/build_tools/java-1.4.1
-
- ## edit $CATALINA_HOME/conf/server.xml, change port 8080 to port 80
- cp $CATALINA_HOME/conf/server.xml $CATALINA_HOME/conf/server.orig
- sed 's/8080/80/g' $CATALINA_HOME/conf/server.orig > $CATALINA_HOME/conf/server.xml
-
- ## install the xenctl web archive
- cp xeno.bk/tools/control/dist/xenctl-0.1-dev.war $CATALINA_HOME/webapps/xenctl.war
- # Only if you have not already copied this file for the command line tool
- cp xeno.bk/tools/control/xenctl.xml /etc
- # If it doesn't exist:
- mkdir /var/lib/xen
-
- ## either edit xi_tools_dir in xenctl.xml or copy the binaries
- ## unless already installed for the command line tool
- # find xeno.bk/tools/internal -perm +111 -type f -exec cp {} /usr/local/bin \;
-
-to run:
- $CATALINA_HOME/bin/startup.sh
- # point your browser at hostname-0.xeno.cl.cam.ac.uk:80/xenctl
-
-
-for development:
- ## edit xeno.bk/tools/control/build.properties
- # change manger.url to your xenoserver: mousetrap-0.xeno.cl.cam.ac.uk
- ## to "make install-web" in xeno.bk/tools/control instead of copying the war file
- cp $CATALINA_HOME/conf/tomcat-users.xml $CATALINA_HOME/conf/tomcat-users.orig
- sed -e 's/<tomcat-users>/<tomcat-users>\\r <role rolename="standard"\/>\\r <role rolename="manager"\/>\\r <user username="hobbes" password="tiger" roles="standard,manager"\/>/' $CATALINA_HOME/conf/tomcat-users.orig > $CATALINA_HOME/conf/tomcat-users.xml
+++ /dev/null
-IMPORTANT! DATA LOSS POTENTIAL!
--------------------------------
-
-It is important that no changes be made to the virtual disk manager through
-the command line while the web interface is running!
-
-If you use the web interface at all, it is NOT safe to call:
-xenctl partitions add
-xenctl vd create
-xenctl vd delete
-xenctl vd refresh
-
-Your changes will likely be lost, or the virtual disks left in an
-inconsistent state, or data on them corrupted or erased.
-
-Other xenctl functions do not modify VDM state and are therefore safe,
-e.g. it's okay to do domain control from the command line if the web
-interface is running.
-
-General
--------
-
-Invoking xenctl with no arguments, or with 'help' gives general usage
-xenctl help command, or xenctl command -?, gives specific command help
-
-Domain control
---------------
-
-xenctl's command line interface is based on domctl. Defaults for domain
-creation are found in /etc/xenctl.xml which has the same format as the
-old domctl.xml
-
-Creating a domain: xenctl domain new <parameters>
-All parameters may be omitted to get defaults from xenctl.xml, see help
-for ful details of available parameters.
-
-Starting a domain: xenctl domain start -n<domain_no>
-Stopping a domain: xenctl domain stop -n<domain_no>
-Destroying a domain: xenctl domain destroy -n<domain_no> (add -f to force
- destruction of a running domain)
-
-Listing all domains: xenctl domain list
-
-Physical disk access management
--------------------------------
-
-Grant read-only access to a disk or partition:
- xenctl physical grant -n<domain_no> -p<partition_name> (e.g. sda10, sdc..etc)
-Grant read-write access to a disk or partition:
- xenctl physical grant -w -n<domain_no> -p<partition_name>
- (if you grant read-write to a domain which already has read for the same
- partition, it will be upgraded quite happily, and vice versa)
-Revoke access to a disk or partition:
- xenctl physical revoke -n<domain_no> -p<partition_name>
-List access a domain has:
- xenctl physical list -n<domain_no>
- will list all the physical disks/partitions which the given domain may access
- and the rights assigned.
-
-Virtual disk management
------------------------
-
-Add a disk partition as a XenoPartition (raw space to create VDs on):
- xenctl partitions add -p<partition_name> -c<chunk_size>
- adds the partition, splitting it up into chunks of the size given
- Sizes can all be specified as k, m, g.
-Lists partitions:
- xenctl partitions list
- XenoPartitions are shown in [ ]
-
-Create a virtual disk:
- xenctl vd create -n<name> -s<size> [-e<expiry>]
- Name is for identification only and need not be unique. Expiry may be none.
- Size can be in k, m, g
- You will be given a 10-digit key for the disk which is its unique identifier.
-Delete a virtual disk:
- xenctl vd delete -k<key>
- Virtual disks with VBDs mapped to them may not be deleted.
-Refresh the expiry on a disk:
- xenctl vd refresh -k<key> [-e<expiry>]
- Sets a new expiry, may be none.
-List virtual disks:
- xenctl vd show
-
-List space free:
- xenctl vd free
- Shows how much space has been added with partitions add, but not allocated
- to a virtual disk.
-
-Create a virtual block device:
- xenctl vbd create -n<domain> -k<key> -v<vbd_number> [-w]
- Maps the disk with the given key into the domain. -w allows read-write.
- vbd number 0 = /dev/xvda, number 1 = /dev/xvdb, and so on.
-Lists virtual block devices:
- xenctl vbd show
-
-Virtual block devices are automatically deleted when their domain is destroyed.
+++ /dev/null
-/local/roots/root1 169.254.1.1(rw,no_root_squash)
-/local/roots/root2 169.254.1.2(rw,no_root_squash)
-/local/roots/root3 169.254.1.3(rw,no_root_squash)
-/local/roots/root4 169.254.1.4(rw,no_root_squash)
-/local/roots/root5 169.254.1.5(rw,no_root_squash)
-/local/roots/root6 169.254.1.6(rw,no_root_squash)
-/local/roots/root7 169.254.1.7(rw,no_root_squash)
-/local/roots/root8 169.254.1.8(rw,no_root_squash)
-
-#/usr 169.254.1/24(ro,no_root_squash)
-
-/local/usrs/usr1 169.254.1.1(rw,no_root_squash)
-/local/usrs/usr2 169.254.1.2(rw,no_root_squash)
-/local/usrs/usr3 169.254.1.3(rw,no_root_squash)
-/local/usrs/usr4 169.254.1.4(rw,no_root_squash)
-/local/usrs/usr5 169.254.1.5(rw,no_root_squash)
-/local/usrs/usr6 169.254.1.6(rw,no_root_squash)
-/local/usrs/usr7 169.254.1.7(rw,no_root_squash)
-/local/usrs/usr8 169.254.1.8(rw,no_root_squash)
-
+++ /dev/null
-# grub.conf
-#
-timeout=10
-
-# We can control GRUB via COM1.
-# Disable by default as it hangs on systems without a serial port and
-# doesn't work with slpashimage enabled anyhow.
-#
-# serial --unit=0 --speed=115200
-# terminal --timeout=10 serial console
-
-# These examples are from the Xen Demo CD, so the root filesystem setup
-# using an initrd to mount the read only /usr is all rather non standard.
-# There are arguably more normal examples in the README.CD file. Read
-# the standard Linux documenation to find out about kernel cmd line
-# parameters.
-
-# The two lots of console= parameters cause the domain 0 Linux to use both
-# the VGA scree consoles and the Xen output-only console
-
-# We also make use of the ability to pass arbitrary environment variables
-# on the kernel command line, so set the DOMID variable.
-
-splashimage=/boot/grub/splash.xpm.gz
-
-default=0
-
-title Xen / XenoLinux 2.4.22
- kernel /boot/image.gz dom0_mem=100000
- module /boot/xenolinux.gz root=/dev/ram0 rw init=/linuxrc console=xencons0 console=tty0 DOMID=0
- module /boot/initrd.gz
-
-title Xen / XenoLinux 2.4.22 w/ cmdline IP config -- edit as required
- kernel /boot/image.gz dom0_mem=100000
- module /boot/xenolinux.gz ip=192.168.5.5::192.168.0.1:255.255.0.0::eth0:off root=/dev/ram0 rw init=/linuxrc console=xencons0 console=tty0 DOMID=0
- module /boot/initrd.gz
-
-title Xen / XenoLinux 2.4.22 in "safe mode"
- kernel /boot/image.gz ignorebiostables watchdog dom0_mem=100000
- module /boot/xenolinux.gz root=/dev/ram0 rw init=/linuxrc console=xencons0 console=tty0 DOMID=0
- module /boot/initrd.gz
-
-
-title Linux 2.4.22
- kernel /boot/vmlinuz-2.4.22 root=/dev/ram0 rw init=/linuxrc
- initrd /boot/initrd.gz
-
-
+++ /dev/null
-domain new
-physical grant -pcdrom_link
-domain start
+++ /dev/null
-<?xml version="1.0"?>
-<domctl_defaults>
-<domain_name>XenoLinux</domain_name>
-<domain_size_kb>98304</domain_size_kb>
-<domain_image>/boot/xenolinux.gz</domain_image>
-<domain_vifs>1</domain_vifs>
-<domain_init_rd>/boot/initrd.gz</domain_init_rd>
-<root_device>/dev/ram0</root_device>
-<root_args>rw</root_args>
-<args>init=/linuxrc 4 DOMID=+</args>
-<nw_ip>169.254.1.0+</nw_ip>
-<nw_gw>169.254.1.0</nw_gw>
-<nw_mask>255.255.0.0</nw_mask>
-<nw_nfs_server>169.254.1.0</nw_nfs_server>
-<max_domain_number>1000</max_domain_number>
-<xi_tools_dir>/usr/local/bin/</xi_tools_dir>
-</domctl_defaults>
+++ /dev/null
-<?xml version="1.0"?>
-<domctl_defaults>
-<domain_name>XenoLinux</domain_name>
-<domain_size_kb>98304</domain_size_kb>
-<domain_image>/boot/xenolinux.gz</domain_image>
-<domain_vifs>1</domain_vifs>
-<root_device>/dev/nfs</root_device>
-<root_args>rw</root_args>
-<args>init=/linuxrc 4 DOMID=+</args>
-<nw_ip>169.254.1.0+</nw_ip>
-<nw_gw>169.254.1.0</nw_gw>
-<nw_mask>255.255.0.0</nw_mask>
-<nw_nfs_server>169.254.1.0</nw_nfs_server>
-<nw_nfs_root>169.254.1.0:/local/roots/root+</nw_nfs_root>
-<max_domain_number>1000</max_domain_number>
-<xi_tools_dir>/usr/local/bin/</xi_tools_dir>
-</domctl_defaults>
+++ /dev/null
-<?xml version="1.0"?>
-<domctl_defaults>
-<domain_name>XenoLinux</domain_name>
-<domain_size_kb>98304</domain_size_kb>
-<domain_image>/boot/xenolinux.gz</domain_image>
-<domain_vifs>1</domain_vifs>
-<domain_init_rd>/boot/initrd.gz</domain_init_rd>
-<root_device>/dev/ram0</root_device>
-<root_args>rw</root_args>
-<args>init=/linuxrc 4 DOMID=+</args>
-<nw_ip>169.254.1.0+</nw_ip>
-<nw_gw>169.254.1.0</nw_gw>
-<nw_mask>255.255.0.0</nw_mask>
-<nw_nfs_server>169.254.1.0</nw_nfs_server>
-<max_domain_number>1000</max_domain_number>
-<xi_tools_dir>/usr/local/bin/</xi_tools_dir>
-</domctl_defaults>
+++ /dev/null
-<?xml version="1.0"?>
-<domctl_defaults>
-<domain_name>XenoLinux</domain_name>
-<domain_size_kb>98304</domain_size_kb>
-<domain_image>/boot/xenolinux.gz</domain_image>
-<domain_vifs>1</domain_vifs>
-<domain_init_rd>/boot/initrd.gz</domain_init_rd>
-<root_device>/dev/ram0</root_device>
-<root_args>rw</root_args>
-<args>init=/linuxrc 4 DOMID=+</args>
-<nw_ip>=+</nw_ip>
-<nw_gw>=</nw_gw>
-<nw_mask>=</nw_mask>
-<nw_nfs_server>169.254.1.0</nw_nfs_server>
-<max_domain_number>10</max_domain_number>
-<xi_tools_dir>/usr/local/bin/</xi_tools_dir>
-</domctl_defaults>
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.Defaults;
-import org.xenoserver.control.PartitionManager;
-import org.xenoserver.control.Settings;
-import org.xenoserver.control.VirtualDiskManager;
-import org.xenoserver.control.XML;
-
-/**
- * Subclasses of Parser know how to parse arguments for a given command
- * and execute it, displaying any output.
- */
-public abstract class CommandParser {
- /**
- * Subclasses should implement this method such that it outputs any successful
- * output to the screen, or throws an exception if required arguments
- * are missing or malformed. It also may propagate exceptions from the
- * command execution.
- *
- * @param d The defaults object to use.
- * @param args The arguments to parse.
- * @throws ParseFailedException if the arguments are not suitable.
- * @throws CommandFailedException if the command did not execute successfully.
- */
- public abstract void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException;
-
- /** @return The command name which will be matched on the command line. */
- public abstract String getName();
- /** @return A usage string for this command. */
- public abstract String getUsage();
- /** @return The help text for this command. */
- public abstract String getHelpText();
-
- /**
- * Print a usage string for this command.
- * @param prefix The command prefix for this command
- */
- public void printUsage(String prefix) {
- String name = getName();
- if (prefix != null) {
- name = prefix + " " + name;
- }
- String usage = getUsage();
- while (name.length() < 16) {
- name = name + " ";
- }
- System.out.println(" " + name + usage);
- }
-
- /**
- * Prints the help text for this command.
- * @param args Command arguments, ignored for normal commands.
- */
- public void printHelpText(LinkedList args) {
- System.out.println(getName() + " " + getUsage());
- System.out.println();
- System.out.println(getHelpText());
- }
-
- /**
- * Get a string parameter
- * @param args Argument list to search
- * @param key Argument key
- * @param def Default value
- * @return parameter, or default if none found
- */
- public String getStringParameter(List args, char key, String def) {
- String r = getParameter(args, key);
- return (r == null) ? def : r;
- }
-
- /**
- * Get an int parameter
- * @param args Argument list to search
- * @param key Argument key
- * @param def Default value
- * @return parameter, or default if none found
- */
- public int getIntParameter(List args, char key, int def) {
- String r = getParameter(args, key);
- return (r == null) ? def : (Integer.parseInt(r.trim()));
- }
-
- /**
- * Get a boolean parameter
- * @param args Argument list to search
- * @param key Argument key
- * @return parameter, or false if none found
- */
- public boolean getFlagParameter(List args, char key) {
- String r = getParameter(args, key);
- return (r == null) ? false : true;
- }
-
- /**
- * Get a parameter
- * @param args Argument list to search
- * @param key Key to look for
- * @return Value, or "" if no value, or null if no such argument
- */
- protected String getParameter(List args, char key) {
- String result = null;
- Iterator i = args.iterator();
- while (i.hasNext()) {
- String arg = (String) i.next();
- if (arg.startsWith("-" + key)) {
- if (arg.length() > 2) {
- result = arg.substring(2);
- } else {
- result = "";
- }
- }
- }
- return result;
- }
-
- /**
- * Load the partition and disk manager state
- */
- protected void loadState() {
- XML.loadState(
- PartitionManager.IT,
- VirtualDiskManager.IT,
- Settings.STATE_INPUT_FILE);
- }
-
- /**
- * Save the partition and disk manager state
- */
- protected void saveState() {
- XML.saveState(
- PartitionManager.IT,
- VirtualDiskManager.IT,
- Settings.STATE_OUTPUT_FILE);
- }
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.LinkedList;
-import java.util.NoSuchElementException;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.Defaults;
-
-/**
- * Main class for the command-line xenctl interface.
- */
-public class Main {
- static final ParseHelp help = new ParseHelp();
- private static final CommandParser domaincommands[] =
- { new ParseDomainNew(),
- new ParseDomainStart(),
- new ParseDomainStop(),
- new ParseDomainDestroy(),
- new ParseDomainList()
- };
- private static final CommandParser partitioncommands[] =
- { new ParsePartitionsAdd(),
- new ParsePartitionsList()
- };
- private static final CommandParser physicalcommands[] =
- { new ParsePhysicalGrant(),
- new ParsePhysicalRevoke(),
- new ParsePhysicalList()
- };
- private static final CommandParser vdcommands[] =
- { new ParseVdCreate(),
- new ParseVdDelete(),
- new ParseVdRefresh(),
- new ParseVdShow(),
- new ParseVdFree()
- };
- private static final CommandParser vbdcommands[] =
- { new ParseVbdCreate(),
- new ParseVbdShow()
- };
- private static final CommandParser commands[] =
- { help,
- new ParseGroup( "domain", domaincommands ),
- new ParseGroup( "partitions", partitioncommands ),
- new ParseGroup( "physical", physicalcommands ),
- new ParseScript(),
- new ParseGroup( "vd", vdcommands ),
- new ParseGroup( "vbd", vbdcommands )
- };
- /** The top-level parser. */
- static final CommandParser parser = new ParseGroup( null, commands );
-
- public static void executeArgList (Defaults d, LinkedList arglist)
- throws ParseFailedException, CommandFailedException
- {
- if (arglist.size() == 0) {
- help.parse(null, null);
- } else {
- parser.parse(d, arglist);
- }
- }
-
- public static void main(String[] args) {
- Defaults d = new Defaults();
- int ec = -1;
- LinkedList arglist = new LinkedList();
- boolean seen_arg = false;
- String collected = null;
- for ( int i=0; i<args.length; i++ ) {
- if (!(args[i].startsWith("-"))) {
- if (seen_arg) {
- collected += " " + args[i];
- } else {
- arglist.add(args[i]);
- }
- }
- if (args[i].startsWith("-")) {
- if (collected != null) {
- arglist.add ( collected );
- collected = null;
- }
- collected = args[i];
- seen_arg = true;
- }
- }
- if (collected != null) {
- arglist.add( collected );
- }
-
- try {
- executeArgList (d, arglist);
- ec = 0;
- } catch (NoSuchElementException e) {
- help.parse(null, null);
- } catch (ParseFailedException e) {
- System.err.println( e.getMessage() );
- } catch (CommandFailedException e) {
- System.err.println( e.getMessage() );
- }
-
- System.exit(ec);
- }
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandDomainDestroy;
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.Defaults;
-
-public class ParseDomainDestroy extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- int domain_id = getIntParameter(args, 'n', d.domainNumber);
- boolean force = getFlagParameter(args, 'f');
-
- if (domain_id == 0) {
- throw new ParseFailedException("Expected -n<domain_id>");
- }
-
- String output = new CommandDomainDestroy(d, domain_id, force).execute();
- if (output != null) {
- System.out.println(output);
- }
- }
-
- public String getName() {
- return "destroy";
- }
-
- public String getUsage() {
- return "[-n<domain_id>] [-f]";
- }
-
- public String getHelpText() {
- return "Destroy the specified domain. -f forcibly destroys it.";
- }
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandDomainList;
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.Defaults;
-import org.xenoserver.control.Domain;
-
-public class ParseDomainList extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- CommandDomainList list = new CommandDomainList(d);
- String output = list.execute();
- if (output != null) {
- System.out.println(output);
- }
-
- Domain[] domains = list.domains();
-
- for (int loop = 0; loop < domains.length; loop++) {
- System.out.println(
- "id: " + domains[loop].id + " (" + domains[loop].name + ")");
- System.out.println(" processor: " + domains[loop].processor);
- System.out.println(" has cpu: " + domains[loop].cpu);
- System.out.println(
- " state: " + domains[loop].nstate + " " + domains[loop].state);
- System.out.println(" mcu advance: " + domains[loop].mcu);
- System.out.println(" total pages: " + domains[loop].pages);
- }
- }
-
- public String getName() {
- return "list";
- }
-
- public String getUsage() {
- return "";
- }
-
- public String getHelpText() {
- return "List domain information and status.";
- }
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandDomainNew;
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.CommandPhysicalGrant;
-import org.xenoserver.control.Defaults;
-import org.xenoserver.control.Mode;
-import org.xenoserver.control.StringPattern;
-
-public class ParseDomainNew extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- String name = getStringParameter(args, 'n', d.domainName);
- int size = getIntParameter(args, 'k', d.domainSizeKB);
- String image = getStringParameter(args, 'i', d.domainImage);
- String initrd = getStringParameter(args, 'r', d.domainInitRD);
- int vifs = getIntParameter(args, 'v', d.domainVIFs);
- String bargs = getStringParameter(args, 'a', d.args);
- String root_dev = getStringParameter(args, 'd', d.rootDevice);
- String root_args = getStringParameter(args, 't', d.rootArgs);
- String usr_dev = getStringParameter(args, 'u', d.usrDevice);
- String nfs_root_path = getStringParameter(args, 'f', d.nwNFSRoot);
- String nw_ip = getStringParameter(args, '4', d.nwIP);
- String nw_gw = getStringParameter(args, 'g', d.nwGateway);
- String nw_mask = getStringParameter(args, 'm', d.nwMask);
- String nw_nfs_server = getStringParameter(args, 's', d.nwNFSServer);
- String nw_host = getStringParameter(args, 'h', d.nwHost);
- int subst = getIntParameter(args, 'x', -1);
-
- d.describe();
-
- CommandDomainNew c =
- new CommandDomainNew(
- d,
- name,
- size,
- image,
- initrd,
- vifs,
- bargs,
- root_dev,
- root_args,
- nfs_root_path,
- nw_ip,
- nw_gw,
- nw_mask,
- nw_nfs_server,
- nw_host,
- usr_dev,
- subst);
- c.execute();
- String[] output = c.output();
- for (int i = 0; i < output.length; i++) {
- System.out.println(output[i]);
- }
-
- if (root_dev.startsWith("/dev/sda") || root_dev.startsWith("/dev/hda")) {
- String real_root = StringPattern.parse(root_dev).resolve(c.domain_id());
- String device = real_root.substring(real_root.indexOf('/',1)+1);
- CommandPhysicalGrant cg = new CommandPhysicalGrant(d,c.domain_id(),device,Mode.READ_WRITE,false,subst);
- String output2 = cg.execute();
- if ( output2 != null ) {
- System.out.println(output2);
- }
- }
-
- if (usr_dev != null && ((usr_dev.startsWith("/dev/sda")) || usr_dev.startsWith("/dev/hda"))) {
- String real_usr = StringPattern.parse(usr_dev).resolve(c.domain_id());
- String device = real_usr.substring(real_usr.indexOf('/',1)+1);
- CommandPhysicalGrant cg = new CommandPhysicalGrant(d,c.domain_id(),device,Mode.READ_ONLY,false,subst);
- String output2 = cg.execute();
- if ( output2 != null ) {
- System.out.println(output2);
- }
- }
- }
-
- public String getName() {
- return "new";
- }
-
- public String getUsage() {
- return "[-n<domain_name>] [-k<size>] [-i<image>] [-v<num_vifs>] [-r<initrd>] [-d<root_device>] [-t<root_mount_args>] [-u<usr_device>] [-f<nfs_root>] [-s<nfs_boot_server>] [-4<ipv4_boot_address>] [-g<ipv4_boot_gateway>] [-m<ipv4_boot_netmask>] [-h<hostname>] [-a<args>] [-x<subst>]";
- }
-
- public String getHelpText() {
- return "Create a new domain. Note that most of the parameters will assume\n"
- + "default values: it should not be necessary to specify them all. See\n"
- + "xenctl.xml for the current default settings.\n"
- + "\n"
- + "General command line options:\n"
- + " -n Domain name domain_name\n"
- + " -k Domain size (kb) domain_size_kb\n"
- + " -i Domain image name domain_image\n"
- + " -v Number of VIFs domain_vifs\n"
- + " -r InitRD (if required) domain_init_rd\n"
- + " -d Root device (e.g /dev/nfs, /dev/hda3) root_device\n"
- + " -t Root mount args (e.g ro) root_args\n"
- + " -u Usr dev/path (e.g /dev/hda3, server:path)usr_device\n"
- + " -a Additional boot parameters args\n"
- + " -x Number to substitute for + if not domain id\n"
- + "\n"
- + "Networking options:\n"
- + " -f NFS root (if /dev/nfs specified) nw_nfs_root\n"
- + " -s NFS server nw_nfs_server\n"
- + " -4 Domain IPv4 address nw_ip\n"
- + " -g Domain gateway nw_gw\n"
- + " -m Domain net mask nw_mask\n"
- + " -h Domain hostname nw_host\n"
- + "\n"
- + "Parameters to -d, -f, -4, -g, -h can be specified as patterns into\n"
- + "which the allocated domain ID will be incorporated. e.g. for\n"
- + "domain 1 patterns would expand as follows:\n"
- + "\n"
- + " /dev/hda+ /dev/hda1\n"
- + " /dev/hda7+ /dev/hda8\n"
- + " 128.232.8.50+ 128.232.8.51\n"
- + "\n"
- + "Additionally, patterns for -4 -g -m can include an = which is\n"
- + "expanded to the corresponding setting from the calling domain.\n";
- }
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandDomainStart;
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.Defaults;
-
-public class ParseDomainStart extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- int domain_id = getIntParameter(args, 'n', d.domainNumber);
-
- if (domain_id == 0) {
- throw new ParseFailedException("Expected -n<domain_id>");
- }
-
- String output = new CommandDomainStart(d, domain_id).execute();
- if (output != null)
- System.out.println(output);
- }
-
- public String getName() {
- return "start";
- }
-
- public String getUsage() {
- return "[-n<domain_id>]";
- }
-
- public String getHelpText() {
- return "Start the specified domain.";
- }
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandDomainStop;
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.Defaults;
-
-public class ParseDomainStop extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- int domain_id = getIntParameter(args, 'n', d.domainNumber);
-
- if (domain_id == 0) {
- throw new ParseFailedException("Expected -n<domain_id>");
- }
-
- String output = new CommandDomainStop(d, domain_id).execute();
- if (output != null)
- System.out.println(output);
- }
-
- public String getName() {
- return "stop";
- }
-
- public String getUsage() {
- return "[-n<domain_id>]";
- }
-
- public String getHelpText() {
- return "Stop the specified domain.";
- }
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-/**
- * Thrown when a command line could not be parsed.
- */
-public class ParseFailedException extends Exception {
- public ParseFailedException(String message) {
- super(message);
- }
-
- public ParseFailedException(String message, Throwable cause) {
- super(message, cause);
- }
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.Defaults;
-
-/**
- * Parses a group of commands; taking the first argument, it searches its
- * array of commands until it finds a match, and then, removing the matched
- * argument from the command line, invokes it. This allows hierarchical
- * parsing.
- */
-public class ParseGroup extends CommandParser {
- /** Name of this group, i.e. the prefix to the command line */
- private final String name;
- /** The commands this group will attempt to match its arguments against. */
- private final CommandParser[] commands;
-
- /**
- * Constructor for ParseGroup.
- * @param name Name of this group of commands
- * @param commands Array of commands to include
- */
- public ParseGroup(String name, CommandParser[] commands) {
- this.name = name;
- this.commands = commands;
- }
-
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- if (args.isEmpty()) {
- Main.help.parse(null,null);
- return;
- }
-
- int i;
- String c = (String) args.removeFirst();
- for (i = 0; i < commands.length; i++) {
- if (commands[i].getName().equals(c)) {
- if (!args.isEmpty() && args.getFirst().equals("-?")) {
- commands[i].printHelpText(null);
- } else {
- commands[i].parse(d, args);
- }
- break;
- }
- }
- if (i == commands.length) {
- throw new ParseFailedException("Unknown command " + c);
- }
- }
-
- public String getName() {
- return name;
- }
-
- public String getUsage() {
- return null;
- }
-
- public String getHelpText() {
- return null;
- }
-
- public void printUsage(String prefix) {
- if (prefix == null) {
- prefix = name;
- } else {
- prefix += " " + name;
- }
- for (int i = 0; i < commands.length; i++) {
- commands[i].printUsage(prefix);
- }
- }
-
- public void printHelpText(LinkedList args) {
- if (args == null) {
- Main.help.parse(null,null);
- return;
- }
- if (name != null) {
- System.out.print(name + " ");
- }
- int i;
- String c = (String) args.removeFirst();
- for (i = 0; i < commands.length; i++) {
- if (commands[i].getName().equals(c)) {
- commands[i].printHelpText(args);
- break;
- }
- }
- }
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.LinkedList;
-
-import org.xenoserver.control.Defaults;
-
-public class ParseHelp extends CommandParser {
- public void parse(Defaults d, LinkedList args) {
- if (args == null || args.isEmpty()) {
- System.out.println("Usage:");
- Main.parser.printUsage(null);
- } else {
- System.out.print("xenctl ");
- Main.parser.printHelpText(args);
- }
-
- System.out.println("");
- }
-
- public String getName() {
- return "help";
- }
-
- public String getUsage() {
- return "[<any command>]";
- }
-
- public String getHelpText() {
- return "This message, or if a command is specified, help for that command.";
- }
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.CommandPartitionAdd;
-import org.xenoserver.control.Defaults;
-import org.xenoserver.control.Library;
-
-public class ParsePartitionsAdd extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- boolean force = getFlagParameter(args, 'f');
- String partition_name = getStringParameter(args, 'p', "");
- String size = getStringParameter(args, 'c', "128M");
-
- if (partition_name.equals("")) {
- throw new ParseFailedException("Expected -p<partition_name>");
- }
-
- loadState();
- String output =
- new CommandPartitionAdd(partition_name, Library.parseSize(size),force)
- .execute();
- if (output != null) {
- System.out.println(output);
- }
- saveState();
- }
-
- public String getName() {
- return "add";
- }
-
- public String getUsage() {
- return "-p<partition_name> [-f] [-c<chunk_size>]";
- }
-
- public String getHelpText() {
- return "Add the specified partition to the virtual disk manager's free\n"
- + "space. -c changes the default chunk size. -f forces add.";
- }
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.Defaults;
-import org.xenoserver.control.Library;
-import org.xenoserver.control.Partition;
-import org.xenoserver.control.PartitionManager;
-
-public class ParsePartitionsList extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- loadState();
- Iterator i = PartitionManager.IT.iterator();
- int idx = 1;
- System.out.println(
- " maj:min "
- + " blocks "
- + "start sect "
- + " num sects "
- + "name");
- while (i.hasNext()) {
- Partition p = (Partition) i.next();
-
- if (p.isXeno()) {
- System.out.print("[ ");
- } else {
- System.out.print(" ");
- }
- System.out.print(Library.format(idx++, 2, false) + " ");
- System.out.print(
- Library.format(p.getMajor(), 3, false)
- + ":"
- + Library.format(p.getMinor(), 3, true)
- + " "
- + Library.format(p.getBlocks(), 10, false)
- + " "
- + Library.format(p.getStartSect(), 10, false)
- + " "
- + Library.format(p.getNumSects(), 10, false)
- + " "
- + Library.format(p.getName(), 7, true));
- if (p.isXeno()) {
- System.out.println("]");
- } else {
- System.out.println();
- }
- }
- }
-
- public String getName() {
- return "list";
- }
-
- public String getUsage() {
- return "";
- }
-
- public String getHelpText() {
- return "List physical partition information. Partitions surrounded by [] are XenoPartitions.";
- }
-
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.CommandPhysicalGrant;
-import org.xenoserver.control.Defaults;
-import org.xenoserver.control.Mode;
-
-public class ParsePhysicalGrant extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- int domain_id = getIntParameter(args, 'n', d.domainNumber);
- boolean force = getFlagParameter(args, 'f');
- String partition_name = getStringParameter(args, 'p', "");
- boolean write = getFlagParameter(args, 'w');
- int subst = getIntParameter(args, 'x', -1);
-
- if (domain_id == 0) {
- throw new ParseFailedException("Expected -n<domain_id>");
- }
- if (partition_name.equals("")) {
- throw new ParseFailedException("Expected -p<partition_name>");
- }
-
- Mode mode;
- if (write) {
- mode = Mode.READ_WRITE;
- } else {
- mode = Mode.READ_ONLY;
- }
-
- // Initialise the partition manager and look up the partition
- loadState();
- String output =
- new CommandPhysicalGrant(d, domain_id, partition_name, mode, force,subst)
- .execute();
- if (output != null) {
- System.out.println(output);
- }
- }
-
- public String getName() {
- return "grant";
- }
-
- public String getUsage() {
- return "-p<partition_name> [-n<domain_id>] [-f] [-w] [-x<subst>]";
- }
-
- public String getHelpText() {
- return "Grant the specified domain access to the given partition. -w grants"
- + " read-write instead of read-only. -f forcibly grants access.";
- }
-
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map.Entry;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.CommandPhysicalList;
-import org.xenoserver.control.Defaults;
-import org.xenoserver.control.Extent;
-import org.xenoserver.control.Library;
-import org.xenoserver.control.Partition;
-import org.xenoserver.control.PartitionManager;
-
-public class ParsePhysicalList extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- int domain_id = getIntParameter(args, 'n', d.domainNumber);
- if (domain_id == 0) {
- throw new ParseFailedException("Expected -n<domain_id>");
- }
-
- // Initialise the partition manager
- loadState();
-
- CommandPhysicalList list = new CommandPhysicalList(d, domain_id);
- String output = list.execute();
- if (output != null) {
- System.out.println(output);
- }
-
- System.out.println(
- "maj:min "
- + " blocks "
- + "start sect "
- + " num sects "
- + "name "
- + "access");
- Iterator i = list.extents().entrySet().iterator();
- while (i.hasNext()) {
- Entry entry = (Entry) i.next();
- Extent e = (Extent) entry.getKey();
- String mode = entry.getValue().toString();
- Partition p = PartitionManager.IT.getPartition(e);
- if (p != null) {
- System.out.println(
- Library.format(p.getMajor(), 3, false)
- + ":"
- + Library.format(p.getMinor(), 3, true)
- + " "
- + Library.format(p.getBlocks(), 10, false)
- + " "
- + Library.format(p.getStartSect(), 10, false)
- + " "
- + Library.format(p.getNumSects(), 10, false)
- + " "
- + Library.format(p.getName(), 7, true)
- + " "
- + Library.format(mode, 2, true));
- } else {
- System.out.println(
- Library.format(e.getMajor(), 3, false)
- + ":"
- + Library.format(
- e.getMinor() | e.getPartitionNo(),
- 3,
- true)
- + " "
- + " "
- + " "
- + Library.format(e.getOffset(), 10, false)
- + " "
- + Library.format(e.getSize(), 10, false)
- + " "
- + " "
- + " "
- + Library.format(mode, 2, true));
- }
- }
- }
-
- public String getName() {
- return "list";
- }
-
- public String getUsage() {
- return "-n<domain_id>";
- }
-
- public String getHelpText() {
- return "List all physical access which the given domain has been granted.";
- }
-
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.CommandPhysicalRevoke;
-import org.xenoserver.control.Defaults;
-
-public class ParsePhysicalRevoke extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- int domain_id = getIntParameter(args, 'n', d.domainNumber);
- String partition_name = getStringParameter(args, 'p', "");
- int subst = getIntParameter(args, 'x', -1);
-
- if (domain_id == 0) {
- throw new ParseFailedException("Expected -n<domain_id>");
- }
- if (partition_name.equals("")) {
- throw new ParseFailedException("Expected -p<partition_name>");
- }
-
- // Initialise the partition manager and look up the partition
- loadState();
- String output = new CommandPhysicalRevoke(d, domain_id, partition_name, subst).execute();
- if (output != null) {
- System.out.println(output);
- }
- }
-
- public String getName() {
- return "revoke";
- }
-
- public String getUsage() {
- return "-p<partition_name> [-n<domain_id>] [-x<subst>]";
- }
-
- public String getHelpText() {
- return "Revoke access to the given partition from the specified domain.";
- }
-
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.StringTokenizer;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.Reader;
-import java.io.InputStreamReader;
-import java.io.IOException;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.Defaults;
-import org.xenoserver.control.Extent;
-import org.xenoserver.control.Library;
-import org.xenoserver.control.Settings;
-import org.xenoserver.control.VirtualDisk;
-import org.xenoserver.control.VirtualDiskManager;
-
-public class ParseScript extends CommandParser {
- public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
- String filename = getStringParameter(args,'f',null);
-
- try
- {
- Reader r;
- BufferedReader br;
- String next_line;
- boolean stdin;
-
- if (filename == null) {
- r = new InputStreamReader (System.in);
- stdin = true;
- } else {
- r = new FileReader (filename);
- stdin = false;
- }
- br = new BufferedReader (r);
-
- if (stdin) prompt();
- while ((next_line = br.readLine()) != null)
- {
- StringTokenizer tok = new StringTokenizer(next_line, " ");
- LinkedList arglist = new LinkedList();
- while (tok.hasMoreTokens()) {
- arglist.add (tok.nextToken ());
- }
- Main.executeArgList (d, arglist);
- if (stdin) prompt();
- }
- }
- catch (IOException ioe)
- {
- throw new ParseFailedException ("Could not read script \"" + filename + "\"", ioe);
- }
- }
-
- void prompt() {
- System.out.print ("$ ");
- System.out.flush ();
- }
-
- public String getName() {
- return "script";
- }
-
- public String getUsage() {
- return "[-f<filename>]";
- }
-
- public String getHelpText() {
- return ("Execute a series of xenctl command lines found in the specified file\n" +
- "(or from standard input if no filename is given). Execution terminates\n" +
- "if any command fails. If a command requires a domain ID then, if\n" +
- "ommitted, the domain most recently created by the script will be used\n" +
- "by default.\n");
- }
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.CommandVbdCreate;
-import org.xenoserver.control.CommandVbdCreatePhysical;
-import org.xenoserver.control.Defaults;
-import org.xenoserver.control.Mode;
-
-public class ParseVbdCreate extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- String vd_key = getStringParameter(args, 'k', "");
- String partition_name = getStringParameter(args, 'p', "");
- int domain_id = getIntParameter(args, 'n', d.domainNumber);
- int vbd_num = getIntParameter(args, 'v', -1);
- boolean write = getFlagParameter(args, 'w');
- int subst = getIntParameter(args, 'x', -1);
-
- if (vd_key.equals("") && partition_name.equals("")) {
- throw new ParseFailedException("Expected -k<key> or -p<partition>");
- }
- if (vbd_num == -1) {
- throw new ParseFailedException("Expected -v<vbd_num>");
- }
-
- Mode mode;
- if (write) {
- mode = Mode.READ_WRITE;
- } else {
- mode = Mode.READ_ONLY;
- }
-
- loadState();
- String output;
- if (vd_key.equals("")) {
- output = new CommandVbdCreatePhysical(d, partition_name, domain_id, vbd_num, mode, subst ).execute();
- } else {
- output =
- new CommandVbdCreate(vd_key, domain_id, vbd_num, mode).execute();
- }
- if (output != null) {
- System.out.println(output);
- }
- saveState();
- }
-
- public String getName() {
- return "create";
- }
-
- public String getUsage() {
- return "{-k<key>|-p<partition} -v<vbd_num> [-n<domain_id>] [-w] [-x<subst>]";
- }
-
- public String getHelpText() {
- return "Create a new virtual block device binding the virtual disk with\n"
- + "the specified key to the domain and VBD number given. Add -w to\n"
- + "allow read-write access.";
- }
-
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.CommandVbdList;
-import org.xenoserver.control.Defaults;
-import org.xenoserver.control.Library;
-import org.xenoserver.control.VirtualBlockDevice;
-
-public class ParseVbdShow extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- loadState();
- CommandVbdList list = new CommandVbdList();
- list.execute();
- VirtualBlockDevice[] vbds = list.vbds();
- System.out.println("key dom vbd mode");
- for (int i=0; i<vbds.length; i++) {
- System.out.println( vbds[i].getVirtualDisk().getKey()
- + " "
- + Library.format(vbds[i].getDomain(), 3, false)
- + " "
- + Library.format(vbds[i].getVbdNum(), 3, false)
- + " "
- + vbds[i].getMode().toString());
- }
- }
-
- public String getName() {
- return "show";
- }
-
- public String getUsage() {
- return "";
- }
-
- public String getHelpText() {
- return "Show details of all mapped virtual block devices.";
- }
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.util.Date;
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.CommandVdCreate;
-import org.xenoserver.control.Defaults;
-import org.xenoserver.control.Library;
-
-public class ParseVdCreate extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- String name = getStringParameter(args, 'n', "");
- String size_s = getStringParameter(args, 's', "");
- String expiry_s = getStringParameter(args, 'e', "");
- Date expiry;
-
- if (name.equals("")) {
- throw new ParseFailedException("Expected -n<name>");
- }
- if (size_s.equals("")) {
- throw new ParseFailedException("Expected -s<size>");
- }
- if (expiry_s.equals("")) {
- expiry = null;
- } else {
- DateFormat format = DateFormat.getDateTimeInstance();
- try {
- expiry = format.parse(expiry_s);
- } catch (ParseException e) {
- throw new ParseFailedException("Could not parse date");
- }
- }
-
- long size = Library.parseSize(size_s);
-
- loadState();
- String output = new CommandVdCreate(name, size, expiry).execute();
- if (output != null) {
- System.out.println(output);
- }
- saveState();
- }
-
- public String getName() {
- return "create";
- }
-
- public String getUsage() {
- return "-n<name> -s<size> [-e<expiry>]";
- }
-
- public String getHelpText() {
- return "Create a new virtual disk with the specified parameters";
- }
-
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.CommandVdDelete;
-import org.xenoserver.control.Defaults;
-
-public class ParseVdDelete extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- String vd_key = getStringParameter(args, 'k', "");
- boolean force = getFlagParameter(args,'f');
-
- if (vd_key.equals("")) {
- throw new ParseFailedException("Expected -k<key>");
- }
-
- loadState();
- String output = new CommandVdDelete(vd_key,force).execute();
- if (output != null) {
- System.out.println(output);
- }
-
- saveState();
- }
-
- public String getName() {
- return "delete";
- }
-
- public String getUsage() {
- return "-k<key> [-f]";
- }
-
- public String getHelpText() {
- return "Deletes the virtual disk with the specified key. -f forces deletion even if the disk is in use.";
- }
-
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.Defaults;
-import org.xenoserver.control.Extent;
-import org.xenoserver.control.Library;
-import org.xenoserver.control.Settings;
-import org.xenoserver.control.VirtualDisk;
-import org.xenoserver.control.VirtualDiskManager;
-
-public class ParseVdFree extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- boolean verbose = getFlagParameter(args, 'v');
-
- loadState();
- VirtualDisk free = VirtualDiskManager.IT.getFreeDisk();
- System.out.println(
- "Free disk has "
- + free.getExtentCount()
- + " extents totalling "
- + Library.formatSize(
- free.getSize() * Settings.SECTOR_SIZE,
- 8,
- true));
- if (verbose) {
- Iterator i = free.extents();
- System.out.println(" disk offset size");
- while (i.hasNext()) {
- Extent e = (Extent) i.next();
- System.out.println(
- Library.format(e.getDisk(), 6, false)
- + " "
- + Library.format(e.getOffset(), 12, false)
- + " "
- + Library.format(e.getSize(), 12, false));
- }
- }
- }
-
- public String getName() {
- return "free";
- }
-
- public String getUsage() {
- return "[-v]";
- }
-
- public String getHelpText() {
- return "Show free space allocated to virtual disk manager. -v enables verbose output.";
- }
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.util.Date;
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.CommandVdRefresh;
-import org.xenoserver.control.Defaults;
-
-public class ParseVdRefresh extends CommandParser {
- public void parse(Defaults d, LinkedList args)
- throws ParseFailedException, CommandFailedException {
- String vd_key = getStringParameter(args, 'k', "");
- String expiry_s = getStringParameter(args, 'e', "");
- Date expiry;
-
- if (vd_key.equals("")) {
- throw new ParseFailedException("Expected -k<key>");
- }
- if (expiry_s.equals("")) {
- expiry = null;
- } else {
- DateFormat format = DateFormat.getDateTimeInstance();
- try {
- expiry = format.parse(expiry_s);
- } catch (ParseException e) {
- throw new ParseFailedException("Could not parse date");
- }
- }
-
- loadState();
- String output = new CommandVdRefresh(vd_key, expiry).execute();
- if (output != null) {
- System.out.println(output);
- }
- saveState();
- }
-
- public String getName() {
- return "refresh";
- }
-
- public String getUsage() {
- return "-k<key> [-e<expiry>]";
- }
-
- public String getHelpText() {
- return "Refresh the expiry for the specified virtual disk. Omitting -e will cause the disk to never expire.";
- }
-
-}
+++ /dev/null
-package org.xenoserver.cmdline;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import org.xenoserver.control.CommandFailedException;
-import org.xenoserver.control.Defaults;
-import org.xenoserver.control.Extent;
-import org.xenoserver.control.Library;
-import org.xenoserver.control.Settings;
-import org.xenoserver.control.VirtualDisk;
-import org.xenoserver.control.VirtualDiskManager;
-
-public class ParseVdShow extends CommandParser {
- public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
- String key = getStringParameter(args,'k',"");
-
- loadState();
-
- if ( key.equals("") ) {
- System.out.println("key expiry name size");
- Iterator i = VirtualDiskManager.IT.getVirtualDisks();
- while ( i.hasNext() ) {
- VirtualDisk vd = (VirtualDisk) i.next();
- System.out.print( vd.getKey() + " " );
- if ( vd.getExpiry() != null ) {
- System.out.print( vd.getExpiry().toString() );
- } else {
- System.out.print( " " );
- }
- System.out.println( " " + Library.format(vd.getName(),16,true) + " "
- + Library.formatSize(vd.getSize()*Settings.SECTOR_SIZE,8,false) );
- }
- } else {
- VirtualDisk vd = VirtualDiskManager.IT.getVirtualDisk(key);
- if ( vd == null ) {
- throw new CommandFailedException("There is no virtual disk " + key );
- }
-
- System.out.println(" name: " + vd.getName());
- System.out.println(" key: " + vd.getKey());
- System.out.println(" size: " + Library.formatSize(vd.getSize()*Settings.SECTOR_SIZE,8,true));
- if ( vd.getExpiry() != null ) {
- System.out.println("expiry: " + vd.getExpiry());
- }
- System.out.println();
-
- Iterator i = vd.extents();
- System.out.println(" disk offset size");
- while (i.hasNext()) {
- Extent e = (Extent) i.next();
- System.out.println( Library.format(e.getDisk(), 6, false) + " "
- + Library.format(e.getOffset(), 12, false) + " "
- + Library.format(e.getSize(), 12, false) );
- }
- }
- }
-
- public String getName() {
- return "show";
- }
-
- public String getUsage() {
- return "[-k<key>]";
- }
-
- public String getHelpText() {
- return "Show a summary of all virtual disks, or details of one disk if -k is given";
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-/**
- * Subclasses of Command are responsible for applying changes to domain
- * and virtual disk settings.
- */
-public abstract class Command {
- /**
- * Subclasses should define an execute method which will apply the
- * relevant change, if possible.
- *
- * @return The results of executing the command, if successful, or null if
- * the command does not need to return results.
- * @throws CommandFailedException if the command could not be completed.
- */
- public abstract String execute() throws CommandFailedException;
-
- /**
- * Wraps execute() suitable for the web interface: all exceptions are
- * converted into output strings.
- * @return Output string, whether command succeeded or not.
- */
- public String executeWeb() {
- try {
- return execute();
- } catch (CommandFailedException e) {
- return e.getMessage();
- }
- }
-
- /**
- * Construct a string to report the execution of a command.
- * @param cmd_array The array of command parameters.
- * @return The report string.
- */
- protected String reportCommand(String[] cmd_array) {
- StringBuffer sb = new StringBuffer();
- int i;
- for (i = 0; i < cmd_array.length; i++) {
- sb.append(cmd_array[i] + " ");
- }
- return sb.toString();
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-/**
- * Destroys a domain.
- */
-public class CommandDomainDestroy extends Command {
- /** Defaults instance in use. */
- private Defaults d;
- /** Domain ID to destroy. */
- private int domain_id;
- /** Force destruction? */
- private boolean force;
-
- /**
- * Constructor for CommandDomainDestroy.
- *
- * @param d Defaults object to use.
- * @param domain_id Domain ID number to destroy.
- * @param force Force destruction.
- */
- public CommandDomainDestroy(Defaults d, int domain_id, boolean force) {
- this.d = d;
- this.domain_id = domain_id;
- this.force = force;
- }
-
- /**
- * @see org.xenoserver.control.Command#execute()
- */
- public String execute() throws CommandFailedException {
- Runtime r = Runtime.getRuntime();
- String output = null;
-
- try {
- Process destroy_p;
- String destroy_cmdarray[] = force ? new String[3] : new String[2];
- int destroy_rc;
- int idx = 0;
- destroy_cmdarray[idx++] = d.xiToolsDir + "xi_destroy";
- if (force) {
- destroy_cmdarray[idx++] = "-f";
- }
- destroy_cmdarray[idx++] = "" + domain_id;
-
- if (Settings.TEST) {
- output = reportCommand(destroy_cmdarray);
- } else {
- destroy_p = r.exec(destroy_cmdarray);
- destroy_rc = destroy_p.waitFor();
-
- if (destroy_rc != 0) {
- throw CommandFailedException.xiCommandFailed(
- "Could not destroy domain",
- destroy_cmdarray);
- }
- output = "Destroyed domain " + domain_id;
- }
- } catch (CommandFailedException e) {
- throw e;
- } catch (Exception e) {
- throw new CommandFailedException(
- "Could not destroy domain (" + e + ")",
- e);
- }
-
- return output;
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-/**
- * Lists details of all domains. After execute() has been called, call
- * domains() to get the array of domains.
- */
-public class CommandDomainList extends Command {
- /** Defaults instance in use. */
- private Defaults d;
- /** Array of domains returned. */
- private Domain[] array;
-
- /**
- * Constructor for CommandDomainList.
- * @param d Defaults object to use.
- */
- public CommandDomainList(Defaults d) {
- this.d = d;
- }
-
- /**
- * Retrieves the list of domains.
- * @return null, call domains() to get the list.
- * @throws CommandFailedException if the list could not be retrieved.
- */
- public String execute() throws CommandFailedException {
- Runtime r = Runtime.getRuntime();
- Vector v = new Vector();
- String outline;
- BufferedReader in;
- String output = null;
-
- try {
- Process start_p;
- String start_cmdarray[] = new String[1];
- int start_rc;
- start_cmdarray[0] = d.xiToolsDir + "xi_list";
-
- if (Settings.TEST) {
- output = reportCommand(start_cmdarray);
- } else {
- start_p = r.exec(start_cmdarray);
- start_rc = start_p.waitFor();
- if (start_rc != 0) {
- throw CommandFailedException.xiCommandFailed(
- "Could not get domain list",
- start_cmdarray);
- }
-
- in =
- new BufferedReader(
- new InputStreamReader(start_p.getInputStream()));
-
- outline = in.readLine();
- while (outline != null) {
- Domain domain = new Domain();
-
- StringTokenizer st = new StringTokenizer(outline);
- if (st.hasMoreTokens()) {
- domain.id = Integer.parseInt(st.nextToken());
- }
- if (st.hasMoreTokens()) {
- domain.processor = Integer.parseInt(st.nextToken());
- }
- if (st.hasMoreTokens()) {
- if (st.nextToken().equals("1")) {
- domain.cpu = true;
- } else {
- domain.cpu = false;
- }
- }
- if (st.hasMoreTokens()) {
- domain.nstate = Integer.parseInt(st.nextToken());
- }
- if (st.hasMoreTokens()) {
- domain.state = st.nextToken().toLowerCase();
- }
- if (st.hasMoreTokens()) {
- domain.ev = Integer.parseInt(st.nextToken());
- }
- if (st.hasMoreTokens()) {
- domain.mcu = Integer.parseInt(st.nextToken());
- }
- if (st.hasMoreTokens()) {
- domain.pages = Integer.parseInt(st.nextToken());
- }
- if (st.hasMoreTokens()) {
- domain.name = st.nextToken();
- }
-
- v.add(domain);
-
- outline = in.readLine();
- }
-
- }
- } catch (CommandFailedException e) {
- throw e;
- } catch (Exception e) {
- throw new CommandFailedException(
- "Could not get domain list(" + e + ")",
- e);
- }
-
- array = new Domain[v.size()];
- v.toArray(array);
- return output;
- }
-
- /**
- * @return Array of domains.
- */
- public Domain[] domains() {
- return array;
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.lang.NumberFormatException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.zip.GZIPInputStream;
-
-/**
- * Creates a new domain. As this command returns a multi-line result,
- * call output() to get an array of strings.
- */
-public class CommandDomainNew extends Command {
- /** Defaults instance in use. */
- private Defaults d;
- /** Name of new domain. */
- private String name;
- /** Memory size for new domain. */
- private int size;
- /** Kernel image */
- private String image;
- /** Initial ramdisk */
- private String initrd;
- /** Num of virtual interfaces */
- private int vifs;
- /** Boot arguments */
- private String bargs;
- /** Root device */
- private String root_dev;
- /** Root mount args */
- private String root_args;
- /** Usr device */
- private String usr_dev;
- /** NFS root path */
- private String nfs_root_path;
- /** IP address */
- private String nw_ip;
- /** Gateway */
- private String nw_gw;
- /** netmask */
- private String nw_mask;
- /** NFS server */
- private String nw_nfs_server;
- /** Hostname */
- private String nw_host;
- /** Output from domain creation */
- private String[] output;
- /** Domain ID created. */
- private int domain_id;
- /** Number to substitute for + (-1 => use domain_id) */
- private int subst;
-
- /**
- * @return Output from domain creation.
- */
- public String[] output() {
- return output;
- }
-
- /**
- * @return The domain id this command created.
- */
- public int domain_id() {
- return domain_id;
- }
-
- /**
- * Constructor for CommandDomainNew.
- * @param d Defaults object to use.
- * @param name Name for the domain.
- * @param size Memory size for the domain.
- * @param image Image to boot domain from.
- * @param initrd Initrd to boot domain with.
- * @param vifs Number of virtual interfaces for the domain.
- * @param bargs Boot arguments for the domain.
- * @param root_dev Root device for the domain.
- * @param nfs_root_path NFS root to be used by the domain.
- * @param nw_ip IP address pattern to use for the domain's interfaces.
- * @param nw_gw Gateway to configure the domain for.
- * @param nw_mask Network mask to configure the domain for.
- * @param nw_nfs_server NFS server to be used by the domain.
- * @param nw_host Hostname to be used by the domain.
- */
- public CommandDomainNew(
- Defaults d,
- String name,
- int size,
- String image,
- String initrd,
- int vifs,
- String bargs,
- String root_dev,
- String root_args,
- String nfs_root_path,
- String nw_ip,
- String nw_gw,
- String nw_mask,
- String nw_nfs_server,
- String nw_host,
- int subst) {
- this(d,name,size,image,initrd,vifs,bargs,root_dev,root_args,nfs_root_path,nw_ip,nw_gw,nw_mask,nw_nfs_server,nw_host,null,subst);
- }
-
- public CommandDomainNew(
- Defaults d,
- String name,
- int size,
- String image,
- String initrd,
- int vifs,
- String bargs,
- String root_dev,
- String root_args,
- String nfs_root_path,
- String nw_ip,
- String nw_gw,
- String nw_mask,
- String nw_nfs_server,
- String nw_host,
- String usr_dev,
- int subst) {
- this.d = d;
- this.name = name;
- this.size = size;
- this.image = image;
- this.initrd = initrd;
- this.vifs = vifs;
- this.bargs = bargs;
- this.root_dev = root_dev;
- this.root_args = root_args;
- this.nfs_root_path = nfs_root_path;
- this.nw_ip = nw_ip;
- this.nw_gw = nw_gw;
- this.nw_mask = nw_mask;
- this.nw_nfs_server = nw_nfs_server;
- this.nw_host = nw_host;
- this.usr_dev = usr_dev;
- this.subst = subst;
- }
-
- /**
- * @see org.xenoserver.control.Command#execute()
- */
- public String execute() throws CommandFailedException {
- Runtime r = Runtime.getRuntime();
- int domain_id = -1;
- BufferedReader br;
- int idx;
- int i;
- File image_tmp = null;
- File initrd_tmp = null;
- String domain_ip = "";
-
- String create_cmdarray[] = new String[3];
- String build_cmdarray[] = new String[6];
- String vifinit_cmdarray[] = new String[4];
-
- try {
- try {
- /* Some initial sanity checks */
- if (root_dev.equals("/dev/nfs") && (vifs == 0)) {
- throw new CommandFailedException("Cannot use NFS root without VIFs configured");
- }
-
- /* Uncompress the image and initrd */
- if (image.endsWith(".gz")) {
- image_tmp = getUncompressed("xen-image-", image);
- image = image_tmp.getPath();
- }
-
- if (initrd != null && initrd.endsWith(".gz")) {
- initrd_tmp = getUncompressed("xen-initrd-", initrd);
- initrd = initrd_tmp.getPath();
- }
-
- /* Create a new empty domain */
- Process create_p;
- int create_rc;
- create_cmdarray[0] = d.xiToolsDir + "xi_create";
- create_cmdarray[1] = "" + size;
- create_cmdarray[2] = name;
- if (Settings.TEST) {
- reportCommand(create_cmdarray);
- domain_id = 1;
- create_rc = 0;
- } else {
- create_p = r.exec(create_cmdarray);
- br =
- new BufferedReader(
- new InputStreamReader(create_p.getInputStream()));
- try
- {
- domain_id = Integer.parseInt(br.readLine());
- }
- catch (NumberFormatException nfe)
- {
- domain_id = -1;
- }
- create_rc = create_p.waitFor();
- }
- d.domainNumber = domain_id;
-
- if (create_rc != 0) {
- throw CommandFailedException.xiCommandFailed(
- "Failed to create domain",
- create_cmdarray);
- } else if (domain_id > d.maxDomainNumber) {
- throw new CommandFailedException(
- "Cannot configure more than "
- + d.maxDomainNumber
- + " domains");
- }
-
- if (subst == -1) subst = domain_id;
-
- /* Set up boot parameters to pass to xi_build. */
- bargs = StringPattern.parse(bargs).resolve(subst) + " ";
- if (root_dev.equals("/dev/nfs")) {
- if (vifs == 0) {
- throw new CommandFailedException("Cannot use NFS root without VIFs configured");
- }
- if (nfs_root_path == null) {
- throw new CommandFailedException("No NFS root specified");
- }
- if (nw_nfs_server == null) {
- throw new CommandFailedException("No NFS server specified");
- }
- bargs =
- (bargs
- + " root=/dev/nfs " + StringPattern.parse(root_args).resolve(subst) + " "
- + "nfsroot="
- + StringPattern.parse(nfs_root_path).resolve(
- subst)
- + " ");
- } else {
- bargs =
- (bargs
- + " root="
- + StringPattern.parse(root_dev).resolve(subst)
- + " " + StringPattern.parse(root_args).resolve(subst) + " ");
-
- }
-
- if (usr_dev != null && !usr_dev.equals("")) {
- bargs = bargs + " usr=" + StringPattern.parse(usr_dev).resolve(subst) + " ";
- }
-
- if (vifs > 0) {
- domain_ip =
- InetAddressPattern.parse(nw_ip).resolve(subst);
- /* if (nw_host == null) {
- try {
- nw_host =
- InetAddress.getByName(domain_ip).getHostName();
- } catch (UnknownHostException uhe) {
- nw_host = "" + nw_ip;
- }
-
- }*/
- bargs =
- ("ip="
- + domain_ip
- + ":"
- + ((nw_nfs_server == null || nw_nfs_server.equals(""))
- ? ""
- : (InetAddressPattern
- .parse(nw_nfs_server)
- .resolve(subst)))
- + ":"
- + ((nw_gw == null || nw_gw.equals(""))
- ? ""
- : (InetAddressPattern
- .parse(nw_gw)
- .resolve(subst)))
- + ":"
- + ((nw_mask == null || nw_mask.equals(""))
- ? ""
- : InetAddressPattern.parse(nw_mask).resolve(
- subst))
- + ":"
- + ((nw_host == null) ? "" : nw_host)
- + ":eth0:off "
- + bargs);
- }
-
- /* Build the domain */
- Process build_p;
- int build_rc;
- idx = 0;
- for (i = 0; i < build_cmdarray.length; i++) {
- build_cmdarray[i] = "";
- }
- build_cmdarray[idx++] = d.xiToolsDir + "xi_build";
- build_cmdarray[idx++] = "" + domain_id;
- build_cmdarray[idx++] = "" + image;
- build_cmdarray[idx++] = "" + vifs;
- if (initrd != null) {
- build_cmdarray[idx++] = "initrd=" + initrd;
- }
- build_cmdarray[idx++] = "" + bargs;
- if (Settings.TEST) {
- reportCommand(build_cmdarray);
- build_rc = 0;
- } else {
- build_p = r.exec(build_cmdarray);
- build_rc = build_p.waitFor();
- }
-
- if (build_rc != 0) {
- throw CommandFailedException.xiCommandFailed(
- "Failed to build domain",
- build_cmdarray);
- }
-
- /* Set up the first VIF if necessary */
- if (vifs > 0) {
- Process vifinit_p;
- int vifinit_rc;
- vifinit_cmdarray[0] = d.xiToolsDir + "xi_vifinit";
- vifinit_cmdarray[1] = "" + domain_id;
- vifinit_cmdarray[2] = "0";
- vifinit_cmdarray[3] = domain_ip;
- if (Settings.TEST) {
- reportCommand(vifinit_cmdarray);
- vifinit_rc = 0;
- } else {
- vifinit_p = r.exec(vifinit_cmdarray);
- vifinit_rc = vifinit_p.waitFor();
- }
-
- if (vifinit_rc != 0) {
- throw CommandFailedException.xiCommandFailed(
- "Failed to initialise VIF 0",
- vifinit_cmdarray);
- }
- }
- } finally {
- if (image_tmp != null) {
- image_tmp.delete();
- }
- if (initrd_tmp != null) {
- initrd_tmp.delete();
- }
- }
- } catch (CommandFailedException e) {
- throw e;
- } catch (Exception e) {
- e.printStackTrace();
- throw new CommandFailedException(
- "Could not create new domain (" + e + ")",
- e);
- }
-
- output = new String[vifs > 0 ? 6 : 4];
- output[0] = "Domain created with arguments:";
- output[1] = "";
- for (i = 0; i < create_cmdarray.length; i++) {
- output[1] += create_cmdarray[i] + " ";
- }
- output[2] = "Domain built with arguments:";
- output[3] = "";
- for (i = 0; i < build_cmdarray.length; i++) {
- output[3] += build_cmdarray[i] + " ";
- }
- if (vifs > 0) {
- output[4] = "VIF 0 initialized with arguments:";
- output[5] = "";
- for (i = 0; i < vifinit_cmdarray.length; i++) {
- output[5] += vifinit_cmdarray[i] + " ";
- }
- }
-
- this.domain_id = domain_id;
-
- return null;
- }
-
- /**
- * Get uncompressed version of file.
- * @param prefix Temp file prefix.
- * @param original Original filename.
- * @return Uncompressed file.
- * @throws IOException if decompression failed.
- */
- private File getUncompressed(String prefix, String original)
- throws IOException {
- FileOutputStream fos;
- GZIPInputStream gis;
- File result;
- byte buffer[] = new byte[1024];
- int l;
-
- result = File.createTempFile(prefix, null);
-
- try {
- fos = new FileOutputStream(result);
- gis = new GZIPInputStream(new FileInputStream(original));
- while ((l = gis.read(buffer, 0, buffer.length)) != -1) {
- fos.write(buffer, 0, l);
- }
- } catch (IOException ioe) {
- result.delete();
- throw ioe;
- }
-
- return result;
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-/**
- * Starts a domain.
- */
-public class CommandDomainStart extends Command {
- /** Defaults instance in use. */
- private Defaults d;
- /** Domain ID to start */
- private int domain_id;
-
- /**
- * Constructor for CommandDomainStart.
- * @param d Defaults object to use.
- * @param domain_id Domain to start.
- */
- public CommandDomainStart(Defaults d, int domain_id) {
- this.d = d;
- this.domain_id = domain_id;
- }
-
- /**
- * @see org.xenoserver.control.Command#execute()
- */
- public String execute() throws CommandFailedException {
- Runtime r = Runtime.getRuntime();
- String output = null;
-
- try {
- Process start_p;
- String start_cmdarray[] = new String[2];
- int start_rc;
- start_cmdarray[0] = d.xiToolsDir + "xi_start";
- start_cmdarray[1] = "" + domain_id;
-
- if (Settings.TEST) {
- output = reportCommand(start_cmdarray);
- } else {
- start_p = r.exec(start_cmdarray);
- start_rc = start_p.waitFor();
- if (start_rc != 0) {
- throw CommandFailedException.xiCommandFailed(
- "Could not start domain",
- start_cmdarray);
- }
- output = "Started domain " + domain_id;
- }
- } catch (CommandFailedException e) {
- throw e;
- } catch (Exception e) {
- throw new CommandFailedException(
- "Could not start new domain (" + e + ")",
- e);
- }
-
- return output;
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-/**
- * Stops a domain.
- */
-public class CommandDomainStop extends Command {
- /** Defaults instance in use */
- private Defaults d;
- /** Domain ID to stop */
- private int domain_id;
-
- /**
- * Constructor for CommandDomainStop.
- * @param d The defaults object to use.
- * @param domain_id The domain to stop.
- */
- public CommandDomainStop(Defaults d, int domain_id) {
- this.d = d;
- this.domain_id = domain_id;
- }
-
- /**
- * @see org.xenoserver.control.Command#execute()
- */
- public String execute() throws CommandFailedException {
- Runtime r = Runtime.getRuntime();
- String output = null;
-
- try {
- Process stop_p;
- String stop_cmdarray[] = new String[2];
- int stop_rc;
- stop_cmdarray[0] = d.xiToolsDir + "xi_stop";
- stop_cmdarray[1] = "" + domain_id;
-
- if (Settings.TEST) {
- output = reportCommand(stop_cmdarray);
- } else {
- stop_p = r.exec(stop_cmdarray);
- stop_rc = stop_p.waitFor();
-
- if (stop_rc != 0) {
- throw CommandFailedException.xiCommandFailed(
- "Could not stop domain",
- stop_cmdarray);
- }
- output = "Stopped domain " + domain_id;
- }
- } catch (CommandFailedException e) {
- throw e;
- } catch (Exception e) {
- throw new CommandFailedException(
- "Could not stop new domain (" + e + ")",
- e);
- }
-
- return output;
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-/**
- * Thrown to indicate that a command failed to execute.
- */
-public class CommandFailedException extends Exception {
- /**
- * Construct an exception with a message.
- * @param message Message to use.
- */
- public CommandFailedException(String message) {
- super(message);
- }
-
- /**
- * Construct an exception with a message and cause.
- * @param message Message to use.
- * @param cause Throwable cause.
- */
- public CommandFailedException(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Construct an exception for an XI command failure.
- * @param message Message to use
- * @param cmd_array Command array used to invoke xi command
- * @return Suitable exception.
- */
- public static CommandFailedException xiCommandFailed(
- String message,
- String cmd_array[]) {
- StringBuffer sb = new StringBuffer();
- int i;
- sb.append(message + " using: ");
- for (i = 0; i < cmd_array.length; i++) {
- sb.append(cmd_array[i] + " ");
- }
- return new CommandFailedException(sb.toString());
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-/**
- * Add a disk partition to the VirtualDiskManager as a XenoPartition.
- */
-public class CommandPartitionAdd extends Command {
- /** True to force creation. */
- private boolean force;
- /** Partition to add as a XenoPartition. */
- private String partition_name;
- /** Chunk size to split partition into (in bytes). */
- private long chunksize;
-
- /**
- * Constructor for CommandPartitionAdd.
- * @param partition_name Partition to add.
- * @param chunksize Chunk size to split partition into (in bytes).
- * @param force True to force creation.
- */
- public CommandPartitionAdd(String partition_name, long chunksize, boolean force) {
- this.partition_name = partition_name;
- this.chunksize = chunksize;
- this.force = force;
- }
-
- /**
- * @see org.xenoserver.control.Command#execute()
- */
- public String execute() throws CommandFailedException {
- Partition p = PartitionManager.IT.getPartition(partition_name);
- if (p == null) {
- throw new CommandFailedException(
- "Partition " + partition_name + " does not exist.");
- }
- // Check if this partition belongs to the VDM
- if (p.isXeno() && !force) {
- throw new CommandFailedException("Refusing to add partition as it is already allocated to the virtual disk manager. Use -f if you are sure.");
- }
-
- long size = chunksize / Settings.SECTOR_SIZE;
- if ( chunksize <= 0 ) {
- throw new CommandFailedException("Chunk size is smaller than sector size.");
- }
-
- VirtualDiskManager.IT.addPartition(p, size);
- PartitionManager.IT.addXenoPartition(p);
- return "Added partition " + p.getName();
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-/**
- * Grant physical access to a partition for a given domain.
- */
-public class CommandPhysicalGrant extends Command {
- /** Defaults instance to use */
- private Defaults d;
- /** Domain ID to grant access for */
- private int domain_id;
- /** Partition to grant access to */
- private String partition_name;
- /** Access mode to grant */
- private Mode mode;
- /** True to force grant */
- private boolean force;
- /** Number to substitute for + (-1 => use domain_id) */
- private int subst;
-
- /**
- * Constructor for CommandPhysicalGrant.
- * @param d Defaults object to use.
- * @param domain_id Domain to grant access for.
- * @param partition Partition to grant access to.
- * @param mode Access mode to grant.
- * @param force True to force grant
- */
- public CommandPhysicalGrant(
- Defaults d,
- int domain_id,
- String partition,
- Mode mode,
- boolean force,
- int subst) {
- this.d = d;
- this.domain_id = domain_id;
- this.partition_name = partition;
- this.mode = mode;
- this.force = force;
- this.subst = subst;
- }
-
- /**
- * @see org.xenoserver.control.Command#execute()
- */
- public String execute() throws CommandFailedException {
- Runtime r = Runtime.getRuntime();
- String output = null;
- String resolved = StringPattern.parse(partition_name).resolve(subst == -1 ? domain_id : subst);
- String resolved2 = d.runCommand(d.xiToolsDir + Settings.XI_HELPER + " expand " + resolved).trim();
- Partition partition = PartitionManager.IT.getPartition(resolved2);
-
- if ( partition == null ) {
- throw new CommandFailedException("Partition " + partition_name + " (resolved to " + resolved2 + ") does not exist.");
- }
-
- // Check if this partition belongs to the VDM
- if (partition.isXeno() && !force) {
- throw new CommandFailedException("Refusing to grant physical access as the given partition is allocated to the virtual disk manager. Use -f if you are sure.");
- }
-
- try {
- Process start_p;
- String start_cmdarray[] = new String[7];
- int start_rc;
- start_cmdarray[0] = d.xiToolsDir + "xi_phys_grant";
- if (mode == Mode.READ_WRITE) {
- start_cmdarray[1] = "rw";
- } else if (mode == Mode.READ_ONLY) {
- start_cmdarray[1] = "ro";
- } else {
- throw new CommandFailedException(
- "Unknown access mode '" + mode + "'");
- }
- start_cmdarray[2] = Integer.toString(domain_id);
- Extent e = partition.toExtent();
- start_cmdarray[3] = Integer.toString(e.getDisk());
- start_cmdarray[4] = Long.toString(e.getOffset());
- start_cmdarray[5] = Long.toString(e.getSize());
- start_cmdarray[6] = Integer.toString(partition.getPartitionIndex());
-
- if (Settings.TEST) {
- output = reportCommand(start_cmdarray);
- } else {
- start_p = r.exec(start_cmdarray);
- start_rc = start_p.waitFor();
- if (start_rc != 0) {
- throw CommandFailedException.xiCommandFailed(
- "Could not grant physical access",
- start_cmdarray);
- }
- output = "Granted physical access to domain " + domain_id;
- }
- } catch (CommandFailedException e) {
- throw e;
- } catch (Exception e) {
- throw new CommandFailedException(
- "Could not grant physical access (" + e + ")",
- e);
- }
-
- return output;
- }
-
-}
+++ /dev/null
-package org.xenoserver.control;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-/**
- * Lists details of all extents the given domain has access to.
- * After execute() has been called, call extents() to get the map of extents
- * to modes.
- */
-public class CommandPhysicalList extends Command {
- /** Domain to list details for */
- private int domain_id;
- /** Defaults instance to use. */
- private Defaults d;
- /** Map of extents to access modes */
- private Map map = new HashMap();
-
- /**
- * Constructor for CommandDomainList.
- * @param d Defaults object to use.
- * @param domain_id Domain ID to query for
- */
- public CommandPhysicalList(Defaults d, int domain_id) {
- this.d = d;
- this.domain_id = domain_id;
- }
-
- /**
- * Retrieves the list of extents.
- * @return null, call extents() to get the list.
- * @throws CommandFailedException if the list could not be retrieved.
- */
- public String execute() throws CommandFailedException {
- Runtime r = Runtime.getRuntime();
- String outline;
- BufferedReader in;
- String output = null;
-
- try {
- Process start_p;
- String start_cmdarray[] = new String[2];
- int start_rc;
- start_cmdarray[0] = d.xiToolsDir + "xi_phys_probe";
- start_cmdarray[1] = Integer.toString(domain_id);
-
- if (Settings.TEST) {
- output = reportCommand(start_cmdarray);
- } else {
- start_p = r.exec(start_cmdarray);
- start_rc = start_p.waitFor();
- if (start_rc != 0) {
- throw CommandFailedException.xiCommandFailed(
- "Could not get extent list",
- start_cmdarray);
- }
-
- in =
- new BufferedReader(
- new InputStreamReader(start_p.getInputStream()));
-
- outline = in.readLine();
- while (outline != null) {
- int disk = -1;
- int partition_no = -1;
- long offset = -1;
- long size = -1;
-
- StringTokenizer st = new StringTokenizer(outline);
- if (st.hasMoreTokens()) {
- disk = Integer.parseInt(st.nextToken(), 16);
- }
- if (st.hasMoreTokens()) {
- partition_no = Integer.parseInt(st.nextToken(), 16);
- }
- if (st.hasMoreTokens()) {
- offset = Long.parseLong(st.nextToken(), 16);
- }
- if (st.hasMoreTokens()) {
- size = Long.parseLong(st.nextToken(), 16);
- }
- if (st.hasMoreTokens()) {
- String mode = st.nextToken();
- Extent extent = new Extent(disk, offset, size, partition_no);
- if (mode.equals("rw")) {
- map.put(extent, Mode.READ_WRITE);
- } else if (mode.equals("r")) {
- map.put(extent, Mode.READ_ONLY);
- } else {
- throw new CommandFailedException(
- "Could not parse access mode " + mode);
- }
- }
-
- outline = in.readLine();
- }
-
- }
- } catch (CommandFailedException e) {
- throw e;
- } catch (Exception e) {
- throw new CommandFailedException(
- "Could not get extent list(" + e + ")",
- e);
- }
-
- return output;
- }
-
- /**
- * @return Map of extents to access modes.
- */
- public Map extents() {
- return map;
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-/**
- * Revoke physical access to a partition from a domain.
- */
-public class CommandPhysicalRevoke extends Command {
- /** Defaults instance to use. */
- private Defaults d;
- /** Domain to revoke access from */
- private int domain_id;
- /** Partition to revoke access to */
- private String partition_name;
- /** Number to substitute for + (-1 => use domain_id) */
- private int subst;
-
- /**
- * Constructor for CommandPhysicalRevoke.
- * @param d Defaults object to use.
- * @param domain_id Domain to revoke access from.
- * @param partition Partition to revoke access to.
- */
- public CommandPhysicalRevoke(Defaults d, int domain_id, String partition, int subst) {
- this.d = d;
- this.domain_id = domain_id;
- this.partition_name = partition;
- this.subst = subst;
- }
-
- /**
- * @see org.xenoserver.control.Command#execute()
- */
- public String execute() throws CommandFailedException {
- Runtime r = Runtime.getRuntime();
- String output = null;
- String resolved = StringPattern.parse(partition_name).resolve(subst == -1 ? domain_id : subst);
- String resolved2 = d.runCommand(d.xiToolsDir + Settings.XI_HELPER + " expand " + resolved).trim();
- Partition partition = PartitionManager.IT.getPartition(resolved2);
-
- if (partition == null) {
- throw new CommandFailedException("Partition " + partition_name + " (resolved to " + resolved2 + ") does not exist.");
- }
-
- try {
- Process start_p;
- String start_cmdarray[] = new String[5];
- int start_rc;
- start_cmdarray[0] = d.xiToolsDir + "xi_phys_revoke";
- start_cmdarray[1] = Integer.toString(domain_id);
- Extent e = partition.toExtent();
- start_cmdarray[2] = Integer.toString(e.getDisk());
- start_cmdarray[3] = Long.toString(e.getOffset());
- start_cmdarray[4] = Long.toString(e.getSize());
-
- if (Settings.TEST) {
- output = reportCommand(start_cmdarray);
- } else {
- start_p = r.exec(start_cmdarray);
- start_rc = start_p.waitFor();
- if (start_rc != 0) {
- throw CommandFailedException.xiCommandFailed(
- "Could not revoke physical access",
- start_cmdarray);
- }
- output = "Revoked physical access from domain " + domain_id;
- }
- } catch (CommandFailedException e) {
- throw e;
- } catch (Exception e) {
- throw new CommandFailedException(
- "Could not revoke physical access (" + e + ")",
- e);
- }
-
- return output;
- }
-
-}
+++ /dev/null
-package org.xenoserver.control;
-
-import java.io.FileWriter;
-import java.io.IOException;
-
-/**
- * Create a virtual block device.
- */
-public class CommandVbdCreate extends Command {
- /** Virtual disk to map to. */
- private String vd_key;
- /** Domain to create VBD for. */
- private int domain_id;
- /** VBD number to use. */
- private int vbd_num;
- /** Access mode to grant. */
- private Mode mode;
-
- /**
- * Constructor for CommandVbdCreate.
- * @param vd VirtualDisk to map to.
- * @param domain_id Domain to map for.
- * @param vbd_num VBD number within domain.
- * @param mode Access mode to grant.
- */
- public CommandVbdCreate(
- String vd,
- int domain_id,
- int vbd_num,
- Mode mode) {
- this.vd_key = vd;
- this.domain_id = domain_id;
- this.vbd_num = vbd_num;
- this.mode = mode;
- }
-
- /**
- * @see org.xenoserver.control.Command#execute()
- */
- public String execute() throws CommandFailedException {
- VirtualDisk vd = VirtualDiskManager.IT.getVirtualDisk(vd_key);
- if (vd == null) {
- throw new CommandFailedException(
- "No virtual disk with key " + vd_key);
- }
-
- VirtualBlockDevice vbd =
- new VirtualBlockDevice(
- vd,
- domain_id,
- vbd_num,
- mode);
- String command = vd.dumpForXen(vbd);
-
- try {
- FileWriter fw = new FileWriter("/proc/xeno/vhd");
- fw.write(command);
- fw.flush();
- fw.close();
- } catch (IOException e) {
- throw new CommandFailedException("Could not write VBD details to /proc/xeno/vhd", e);
- }
-
- return "Created virtual block device "
- + vbd_num
- + " for domain "
- + domain_id;
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-import java.io.FileWriter;
-import java.io.IOException;
-
-/**
- * Create a virtual block device.
- */
-public class CommandVbdCreatePhysical extends Command {
- /** Defaults instance to use. */
- private Defaults d;
- /** Virtual disk to map to. */
- private String partition_name;
- /** Domain to create VBD for. */
- private int domain_id;
- /** VBD number to use. */
- private int vbd_num;
- /** Access mode to grant. */
- private Mode mode;
- /** Number to substitute for + (-1 => use domain_id) */
- private int subst;
-
- /**
- * Constructor for CommandVbdCreate.
- * @param partition Partition to map to.
- * @param domain_id Domain to map for.
- * @param vbd_num VBD number within domain.
- * @param mode Access mode to grant.
- */
- public CommandVbdCreatePhysical(
- Defaults d,
- String partition,
- int domain_id,
- int vbd_num,
- Mode mode,
- int subst) {
- this.d = d;
- this.partition_name = partition;
- this.domain_id = domain_id;
- this.vbd_num = vbd_num;
- this.mode = mode;
- this.subst = subst;
- }
-
- /**
- * @see org.xenoserver.control.Command#execute()
- */
- public String execute() throws CommandFailedException {
- String resolved = StringPattern.parse(partition_name).resolve(subst == -1 ? domain_id : subst);
- String resolved2 = d.runCommand(d.xiToolsDir + Settings.XI_HELPER + " expand " + resolved).trim();
- Partition partition = PartitionManager.IT.getPartition(resolved2);
- if (partition == null) {
- throw new CommandFailedException(
- "No partition " + partition_name + " (resolved to " + resolved2 + ") exists");
- }
-
- VirtualDisk vd = new VirtualDisk("vbd:" + partition.getName());
- vd.addPartition(partition, partition.getNumSects());
-
- VirtualBlockDevice vbd =
- new VirtualBlockDevice(vd, domain_id, vbd_num, mode);
-
- String command = vd.dumpForXen(vbd);
-
- try {
- FileWriter fw = new FileWriter("/proc/xeno/vhd");
- fw.write(command);
- fw.flush();
- fw.close();
- } catch (IOException e) {
- throw new CommandFailedException(
- "Could not write VBD details to /proc/xeno/vhd",
- e);
- }
-
- return "Created virtual block device "
- + vbd_num
- + " for domain "
- + domain_id;
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-public class CommandVbdList extends Command {
- /** Array of virtual block devices returned */
- private VirtualBlockDevice[] array;
-
- public String execute() throws CommandFailedException {
- Vector v = new Vector();
- BufferedReader in;
- String line;
-
- try {
- in = new BufferedReader(new FileReader("/proc/xeno/vhd"));
- line = in.readLine();
- while (line != null) {
- int domain = -1;
- int vbdnum = -1;
- String key = "";
- Mode mode = Mode.READ_ONLY;
-
- StringTokenizer st = new StringTokenizer(line);
- if (st.hasMoreTokens()) {
- domain = Integer.parseInt(st.nextToken());
- }
- if (st.hasMoreTokens()) {
- vbdnum = Integer.parseInt(st.nextToken());
- }
- if (st.hasMoreTokens()) {
- key = st.nextToken();
- }
- if (st.hasMoreTokens()) {
- if (Integer.parseInt(st.nextToken()) == 1) {
- mode = Mode.READ_WRITE;
- }
- }
-
- VirtualDisk vd = VirtualDiskManager.IT.getVirtualDisk(key);
- if (vd == null) {
- throw new CommandFailedException(
- "Key " + key + " has no matching virtual disk");
- }
- VirtualBlockDevice vbd =
- new VirtualBlockDevice(vd, domain, vbdnum, mode);
- v.add(vbd);
-
- line = in.readLine();
- }
- } catch (IOException e) {
- throw new CommandFailedException("Could not read VBD file", e);
- }
-
- array = new VirtualBlockDevice[v.size()];
- v.toArray(array);
- return null;
- }
-
- public VirtualBlockDevice[] vbds() {
- return array;
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-import java.util.Date;
-
-/**
- * Create a virtual disk.
- */
-public class CommandVdCreate extends Command {
- /** Name of new disk. */
- private String name;
- /** Size of new disk in bytes. */
- private long size;
- /** Expiry date of new disk. */
- private Date expiry;
-
- /**
- * Constructor for CommandVdCreate.
- * @param name Name of new virtual disk.
- * @param size Size in bytes.
- * @param expiry Expiry time, or null for never.
- */
- public CommandVdCreate(String name, long size, Date expiry) {
- this.name = name;
- this.size = size;
- this.expiry = expiry;
- }
-
- /**
- * @see org.xenoserver.control.Command#execute()
- */
- public String execute() throws CommandFailedException {
- VirtualDisk vd =
- VirtualDiskManager.IT.createVirtualDisk(
- name,
- size / Settings.SECTOR_SIZE,
- expiry);
- if (vd == null) {
- throw new CommandFailedException("Not enough free space to create disk");
- }
- return "Virtual Disk created with key: " + vd.getKey();
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-/**
- * Delete virtual disk.
- */
-public class CommandVdDelete extends Command {
- /** Key of disk to delete. */
- private String key;
- /** Force deletion? */
- private boolean force;
-
- /**
- * Constructor for CommandVdDelete.
- * @param key The key of the disk to delete.
- */
- public CommandVdDelete(String key,boolean force) {
- this.key = key;
- this.force = force;
- }
-
- /**
- * @see org.xenoserver.control.Command#execute()
- */
- public String execute() throws CommandFailedException {
- if (VirtualDiskManager.IT.getVirtualDisk(key) == null) {
- throw new CommandFailedException(
- "Virtual disk " + key + " does not exist");
- }
- if ( !force ) {
- CommandVbdList list = new CommandVbdList();
- list.execute();
- VirtualBlockDevice[] vbds = list.vbds();
- for (int i=0;i<vbds.length;i++) {
- if (vbds[i].getVirtualDisk().getKey().equals(key)) {
- throw new CommandFailedException("Virtual disk " + key + " is in use.");
- }
- }
- }
-
- VirtualDiskManager.IT.deleteVirtualDisk(key);
- return "Deleted virtual disk " + key;
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-import java.util.Date;
-
-/**
- * Refresh the expiry time on a virtual disk.
- */
-public class CommandVdRefresh extends Command {
- /** Key of disk to refresh */
- private String key;
- /** New expiry */
- private Date expiry;
-
- /**
- * Constructor for CommandVdRefresh.
- * @param key Key to refresh.
- * @param expiry New expiry (null for no expiry).
- */
- public CommandVdRefresh(String key, Date expiry) {
- this.key = key;
- this.expiry = expiry;
- }
-
- /**
- * @see org.xenoserver.control.Command#execute()
- */
- public String execute() throws CommandFailedException {
- VirtualDisk vd = VirtualDiskManager.IT.getVirtualDisk(key);
- if (vd == null) {
- throw new CommandFailedException("No such virtual disk " + key);
- }
- vd.refreshExpiry(expiry);
- return "Refreshed virtual disk " + key;
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * The Defaults class stores the default settings to be used by the
- * management utilities. On construction it parses the defaults file
- * located through the Settings class.
- */
-public class Defaults {
- /** Default domain name. */
- public String domainName;
- /** Default domain memory size in KB. */
- public int domainSizeKB;
- /** Default domain kernel image. */
- public String domainImage;
- /** Default domain initrd. */
- public String domainInitRD;
- /** Default number of virtual interfaces. */
- public int domainVIFs;
- /** Default root device. */
- public String rootDevice;
- /** Default root mount args */
- public String rootArgs;
- /** Default usr device. */
- public String usrDevice;
- /** Default IP address pattern. */
- public String nwIP;
- /** Default gateway pattern. */
- public String nwGateway;
- /** Default netmask patterh. */
- public String nwMask;
- /** Default hostname pattern. */
- public String nwHost;
- /** Default NFS server pattern. */
- public String nwNFSServer;
- /** Default NFS root pattern. */
- public String nwNFSRoot;
- /** Maximum domain number. */
- public int maxDomainNumber = Integer.MAX_VALUE;
- /** Default boot arguments. */
- public String args = "";
- /** Directory to find XI tools. */
- public String xiToolsDir = "";
- /** Domain number */
- public int domainNumber;
-
-
- /**
- * Create defaults instance and parse the defaults file.
- */
- public Defaults() {
- File f = Settings.getDefaultsFile();
-
- if (f == null) {
- return;
- }
-
- try {
- XMLReader xr = new org.apache.crimson.parser.XMLReaderImpl();
- Handler handler = new Handler();
- xr.setContentHandler(handler);
- xr.setErrorHandler(handler);
- xr.parse(new InputSource(new FileReader(f)));
- } catch (Exception e) {
- System.err.println(
- "Could not read defaults file " + f + "\nException: " + e);
- e.printStackTrace();
- return;
- }
- }
-
- /**
- * Describe the defaults to System.out
- */
- public void describe() {
- System.out.println("Domain defaults:");
- System.out.println(" name " + domainName);
- System.out.println(" size " + domainSizeKB);
- System.out.println(" vifs " + domainVIFs);
- System.out.println(" domainImage " + domainImage);
- System.out.println(" domainInitRD " + domainInitRD);
- System.out.println(" rootDevice " + rootDevice);
- System.out.println(" rootArgs " + rootArgs);
- System.out.println(" usrDevice " + usrDevice);
- System.out.println(" NWIP " + nwIP);
- System.out.println(" NWGW " + nwGateway);
- System.out.println(" NWMask " + nwMask);
- System.out.println(" MaxDomainNumber " + maxDomainNumber);
- System.out.println(" NWNFSServer " + nwNFSServer);
- System.out.println(" NWNFSRoot " + nwNFSRoot);
- System.out.println(" XIToolsDir " + xiToolsDir);
- System.out.println(" args " + args);
- }
-
- /**
- * SAX event handler.
- */
- private class Handler extends DefaultHandler {
- /** Are we inside the defaults node. */
- boolean inDomctlDefaults;
- /** Last element name read. */
- String lastName;
-
- /**
- * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
- */
- public void startElement(
- String uri,
- String name,
- String qname,
- Attributes atts) {
- if (qname.equals("domctl_defaults")) {
- inDomctlDefaults = true;
- } else {
- lastName = qname;
- }
- }
-
- /**
- * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
- */
- public void endElement(String uri, String name, String qname) {
- lastName = "";
- if (qname.equals("domctl_defaults")) {
- inDomctlDefaults = false;
- }
- }
-
- /**
- * @see org.xml.sax.ContentHandler#characters(char[], int, int)
- */
- public void characters(char ch[], int start, int length) {
- String s = new String(ch, start, length);
- if (lastName != null) {
- if (lastName.equals("domain_size_kb")) {
- domainSizeKB = Integer.parseInt(s);
- } else if (lastName.equals("domain_image")) {
- domainImage = s;
- } else if (lastName.equals("domain_name")) {
- domainName = s;
- } else if (lastName.equals("domain_number")) {
- domainNumber = Integer.parseInt(s);
- } else if (lastName.equals("domain_init_rd")) {
- domainInitRD = s;
- } else if (lastName.equals("domain_vifs")) {
- domainVIFs = Integer.parseInt(s);
- } else if (lastName.equals("root_device")) {
- rootDevice = s;
- } else if (lastName.equals("root_args")) {
- rootArgs = s;
- } else if (lastName.equals("usr_device")) {
- usrDevice = s;
- } else if (lastName.equals("nw_ip")) {
- nwIP =
- expandDefault(
- s,
- runCommand(xiToolsDir + Settings.XI_HELPER + " ip")
- .trim());
- } else if (lastName.equals("nw_gw")) {
- nwGateway =
- expandDefault(
- s,
- runCommand(
- xiToolsDir + Settings.XI_HELPER + " route")
- .trim());
- } else if (lastName.equals("nw_mask")) {
- nwMask =
- expandDefault(
- s,
- runCommand(
- xiToolsDir + Settings.XI_HELPER + " mask")
- .trim());
- } else if (lastName.equals("nw_host")) {
- nwHost = s;
- } else if (lastName.equals("nw_nfs_server")) {
- nwNFSServer = s;
- } else if (lastName.equals("nw_nfs_root")) {
- nwNFSRoot = s;
- } else if (lastName.equals("args")) {
- args = s;
- } else if (lastName.equals("max_domain_number")) {
- maxDomainNumber = Integer.parseInt(s);
- } else if (lastName.equals("xi_tools_dir")) {
- xiToolsDir = s;
- }
- }
- }
- }
-
- /**
- * Expand a defaults pattern.
- * @param supplied Supplied pattern.
- * @param self Own value for variable.
- * @return Appropriate value.
- */
- private String expandDefault(String supplied, String self) {
- if (supplied.startsWith("=")) {
- if (supplied.length() > 1) {
- return self + supplied.substring(1, supplied.length());
- } else {
- return self;
- }
- } else {
- return supplied;
- }
- }
-
- /**
- * Run a command for the Defaults object.
- * @param command Command string to run.
- * @return Command's output.
- */
- String runCommand(String command) {
- Runtime runtime = Runtime.getRuntime();
- String outline;
- StringBuffer output = new StringBuffer();
-
- try {
- Process process = runtime.exec(command);
- BufferedReader in =
- new BufferedReader(
- new InputStreamReader(process.getInputStream()));
-
- outline = in.readLine();
- while (outline != null) {
- output.append("\n" + outline);
- outline = in.readLine();
- }
- } catch (IOException e) {
- return e.toString();
- }
-
- return output.toString();
- }
-
-}
+++ /dev/null
-package org.xenoserver.control;
-
-/**
- * A Domain object holds the details of one domain suitable for returning
- * from methods enquiring about domain status. As it's only used to pass
- * return values back from DomainList, the fields are left public for
- * convenience.
- */
-public class Domain {
- /** Domain ID. */
- public int id;
- /** Processor index. */
- public int processor;
- /** Has the CPU at the moment? */
- public boolean cpu;
- /** State index. */
- public int nstate;
- /** State string. */
- public String state;
- /** State string. */
- public int ev;
- /** MCU advances. */
- public int mcu;
- /** Total pages. */
- public int pages;
- /** Name. */
- public String name;
-
- /**
- * Domain constructor, with default values.
- */
- Domain() {
- id = 0;
- processor = 0;
- cpu = false;
- nstate = 0;
- state = "";
- mcu = 0;
- pages = 0;
- name = "none";
- }
-}
+++ /dev/null
-/*
- * Extent.java
- * 03.03.26 aho creation
- */
-
-package org.xenoserver.control;
-
-/**
- * Represents an extent on physical disk.
- */
-public class Extent {
- /** Disk number; 16-bit major:minor pair with no partition number. */
- private int disk;
- /** Offset into disk in sectors. */
- private long offset;
- /** Size of extent in sectors. */
- private long size;
- /** Partition number, if one is allocated. */
- private int partition_no;
-
- /**
- * Constructor for Extent.
- * @param disk Disk number.
- * @param offset Offset into disk.
- * @param size Size of extent.
- */
- Extent(int disk, long offset, long size) {
- this.disk = disk;
- this.offset = offset;
- this.size = size;
- }
-
- /**
- * Constructor for Extent.
- * @param disk Disk number.
- * @param offset Offset into disk.
- * @param size Size of extent.
- * @param partition_no Partition number.
- */
- Extent(int disk, long offset, long size,int partition_no) {
- this.disk = disk;
- this.offset = offset;
- this.size = size;
- this.partition_no = partition_no;
- }
-
- /**
- * @return Disk number.
- */
- public int getDisk() {
- return disk;
- }
-
- /**
- * @return Offset into disk.
- */
- public long getOffset() {
- return offset;
- }
-
- /**
- * @return Size of extent.
- */
- public long getSize() {
- return size;
- }
-
- /**
- * @return Major number of disk.
- */
- public int getMajor() {
- return disk >> 8;
- }
-
- /**
- * @return Minor number of disk, not including partition.
- */
- public int getMinor() {
- return disk & 0xFF;
- }
-
- /**
- * @return Partition number of this extent.
- */
- public int getPartitionNo() {
- return partition_no;
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-/**
- * This utility class expands configuration file patterns.
- */
-public class InetAddressPattern {
- /** The base InetAddress for this pattern. */
- private InetAddress base;
- /** If true, add the domain number to the base address. */
- private boolean addDom;
-
- /**
- * Parse a pattern string into an InetAddressPattern.
- * @param t The pattern string.
- * @return The parsed pattern object.
- */
- static InetAddressPattern parse(String t) {
- InetAddressPattern result = new InetAddressPattern();
- char[] ca = t.toCharArray();
- int len = ca.length;
-
- try {
- if (len == 0) {
- result.base = null;
- result.addDom = false;
- } else if (ca[len - 1] == '+') {
- result.base = InetAddress.getByName(t.substring(0, len - 1));
- result.addDom = true;
- } else {
- result.base = InetAddress.getByName(t);
- result.addDom = false;
- }
- } catch (UnknownHostException uhe) {
- result.base = null;
- result.addDom = false;
- }
-
- return result;
- }
-
- /**
- * Resolve the pattern for the given domain.
- * @param domain_id The domain ID.
- * @return The resolved string.
- */
- String resolve(int domain_id) {
- byte[] b = base.getAddress();
- if (addDom) {
- if (((int) b[3]) + domain_id > 255) {
- if (((int) b[2]) + domain_id > 255) {
- if (((int) b[1]) + domain_id > 255) {
- b[0]++;
- }
- b[1]++;
- }
- b[2]++;
- }
- b[3] += domain_id;
- }
- return ""
- + (b[0] + (b[0] < 0 ? 256 : 0))
- + "."
- + (b[1] + (b[1] < 0 ? 256 : 0))
- + "."
- + (b[2] + (b[2] < 0 ? 256 : 0))
- + "."
- + (b[3] + (b[3] < 0 ? 256 : 0));
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return "[" + base + (addDom ? "+dom_id" : "") + "]";
- }
-}
+++ /dev/null
-/*
- * Library.java
- * 03.03.28 aho creation
- */
-
-package org.xenoserver.control;
-
-/**
- * Library functions.
- */
-public class Library {
- /**
- * Convert a number to a fixed width string.
- * @param input The number to convert.
- * @param width The width desired.
- * @param leftAlign True to left-align the number.
- * @return The formatted string.
- */
- public static String format(long input, int width, boolean leftAlign) {
- String sss = Long.toString(input);
- String space = " ";
-
- if (width < sss.length()) {
- width = sss.length();
- }
-
- if (leftAlign) {
- return sss + space.substring(0, width - sss.length());
- } else {
- return space.substring(0, width - sss.length()) + sss;
- }
- }
-
- /**
- * Convert a string to a fixed-width string.
- * @param input Input string.
- * @param width Width desired.
- * @param leftAlign True to left-align the string.
- * @return The formatted string.
- */
- public static String format(String input, int width, boolean leftAlign) {
- String space = " ";
-
- if (width < input.length()) {
- width = input.length();
- }
-
- if (leftAlign) {
- return input + space.substring(0, width - input.length());
- } else {
- return space.substring(0, width - input.length()) + input;
- }
- }
-
- /**
- * Parse a size which may have a k/m/g suffix into a number.
- * @param size The size string to parse.
- * @return The equivalent number.
- */
- public static long parseSize(String size) {
- String substring = size;
- int suffix = 1;
- long value = 0;
-
- if (size == null) {
- return 0;
- }
-
- if ((substring = check(size, 'm')) != null) {
- suffix = 1024 * 1024;
- } else if ((substring = check(size, 'M')) != null) {
- suffix = 1024 * 1024;
- } else if ((substring = check(size, 'k')) != null) {
- suffix = 1024;
- } else if ((substring = check(size, 'K')) != null) {
- suffix = 1024;
- } else if ((substring = check(size, 'g')) != null) {
- suffix = 1024 * 1024 * 1024;
- } else if ((substring = check(size, 'G')) != null) {
- suffix = 1024 * 1024 * 1024;
- } else {
- substring = size;
- }
-
- try {
- value = Long.decode(substring).longValue() * suffix;
- } catch (NumberFormatException e) {
- value = 0;
- }
-
- return value;
- }
-
- /**
- * Check if the given size has the specified suffix.
- * @param size Size string.
- * @param suffix Test suffix.
- * @return Number part of string, or null if suffix does not match.
- */
- private static String check(String size, char suffix) {
- int index = size.indexOf(suffix);
-
- if (index != -1) {
- return size.substring(0, index);
- } else {
- return null;
- }
- }
-
- /**
- * Formats a number of bytes in whichever way makes most sense based
- * on magnitude and width.
- *
- * @param size Number of bytes.
- * @param width Width of field - at least 5, plz.
- * @param leftAlign True for left-align.
- * @return The formatted string.
- */
- public static String formatSize(long size, int width, boolean leftAlign) {
- char[] suffixes = { ' ', 'k', 'M', 'G' };
- int suffix = 0;
- long before = size;
- float after = 0;
-
- while (before > 10000) {
- after = ((float) (before % 1024)) / 1024;
- before /= 1024;
- suffix++;
- }
-
- StringBuffer num = new StringBuffer(width);
- num.append(Long.toString(before));
- if (after != 0) {
- int space = width - num.length() - 2;
- if (space > 0) {
- num.append('.');
- if (space > 3) {
- space = 3;
- }
- num.append(
- Integer.toString((int) (after * Math.pow(10, space))));
- }
- }
- num.append(suffixes[suffix]);
-
- return format(num.toString(), width, leftAlign);
- }
-}
+++ /dev/null
-/*
- * Mode.java
- * 03.03.27 aho creation
- *
- * until we have jdk1.5, we're left with this mess...
- */
-
-package org.xenoserver.control;
-
-/**
- * Enumeration to represent an access mode.
- */
-public class Mode {
- /** name of this mode */
- private final String name;
-
- /**
- * Construct a mode
- * @param name Name to use.
- */
- private Mode(String name) {
- this.name = name;
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return name;
- }
-
- /** Single read-only mode instance. */
- public static final Mode READ_ONLY = new Mode("ro");
- /** Single read-write mode instance. */
- public static final Mode READ_WRITE = new Mode("rw");
-}
+++ /dev/null
-/*
- * Partition.java
- * 03.03.26 aho creation
- */
-
-package org.xenoserver.control;
-
-import java.io.PrintWriter;
-
-/**
- * Represents a single real partition.
- */
-public class Partition {
- /** Major device number as seen by Linux. */
- private int major;
- /** Minor device number as seen by Linux. */
- private int minor;
- /** Number of blocks in the partition. */
- private long blocks;
- /** Start sector of the partition. */
- private long start_sect;
- /** Number of sectors in the partition. */
- private long nr_sects;
- /** Name of the partition. */
- private String name;
- /** True if this partition is a XenoPartition. */
- private boolean xeno;
-
- /**
- * Mark this partition as a XenoPartition.
- */
- void makeXeno() {
- xeno = true;
- }
-
- /**
- * Constructor for Partition.
- * @param major Major number
- * @param minor Minor number
- * @param blocks Size in blocks
- * @param start_sect Start sector
- * @param nr_sects Number of sectors
- * @param name Name of partition
- * @param xeno True if XenoPartition
- */
- Partition(
- int major,
- int minor,
- long blocks,
- long start_sect,
- long nr_sects,
- String name,
- boolean xeno) {
- this.major = major;
- this.minor = minor;
- this.blocks = blocks;
- this.start_sect = start_sect;
- this.nr_sects = nr_sects;
- this.name = name;
- this.xeno = xeno;
- }
-
- /**
- * Dump this partition as XML.
- * @param out The writer to dump to.
- */
- void dumpAsXML(PrintWriter out) {
- out.println(
- " <partition>\n"
- + " <major>"
- + major
- + "</major>\n"
- + " <minor>"
- + minor
- + "</minor>\n"
- + " <blocks>"
- + blocks
- + "</blocks>\n"
- + " <start_sect>"
- + start_sect
- + "</start_sect>\n"
- + " <nr_sects>"
- + nr_sects
- + "</nr_sects>\n"
- + " <name>"
- + name
- + "</name>\n"
- + " </partition>");
- }
-
- /**
- * @return Major device number.
- */
- public int getMajor() {
- return major;
- }
-
- /**
- * @return Minor device number.
- */
- public int getMinor() {
- return minor;
- }
-
- /**
- * @return Number of blocks.
- */
- public long getBlocks() {
- return blocks;
- }
-
- /**
- * @return Starting sector.
- */
- public long getStartSect() {
- return start_sect;
- }
-
- /**
- * @return Number of sectors.
- */
- public long getNumSects() {
- return nr_sects;
- }
-
- /**
- * @return Name of partition.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @return True if this is a XenoPartition.
- */
- public boolean isXeno() {
- return xeno;
- }
-
- /**
- * Is this partition identical to the other?
- * @param other Other partition to compare to.
- * @return True if they are identical.
- */
- boolean identical(Partition other) {
- return this.major == other.major
- && this.minor == other.minor
- && this.blocks == other.blocks
- && this.start_sect == other.start_sect
- && this.nr_sects == other.nr_sects
- && this.name.equals(other.name);
- }
-
- /**
- * @return An Extent covering this partiton.
- */
- Extent toExtent() {
- return new Extent(getDisk(),start_sect,nr_sects);
- }
-
- /**
- * @param e Extent to compare this partition to.
- * @return True if this partition covers the same disk area as the given extent.
- */
- boolean matchesExtent(Extent e) {
- return e.getDisk() == getDisk()
- && e.getOffset() == start_sect
- && e.getSize() == nr_sects;
- }
-
- /**
- * @return Disk number for this partition.
- */
- public int getDisk() {
- if ( name.startsWith("hd") ) {
- // High 8 bits are major, low 8 bits are minor, with bottom 6 clear
- return (major << 8) | (minor & 0xC0);
- } else if ( name.startsWith("sd") ) {
- // High 8 bits are major, low 8 bits are minor, with bottom 4 clear
- return (major << 8) | (minor & 0xF0);
- } else {
- throw new IllegalArgumentException("Don't know how to convert " + name + "into a disk number");
- }
- }
-
- /**
- * @return Partition index on disk for this partition.
- */
- public int getPartitionIndex() {
- if ( name.startsWith("hd") ) {
- // low 6 bits of minor are partition no
- return minor & 0x3F;
- } else if ( name.startsWith("sd") ) {
- // low 4 bits of minor are partition no
- return minor & 0x0F;
- } else {
- throw new IllegalArgumentException("Don't know how to convert " + name + "into a partition number");
- }
- }
-}
+++ /dev/null
-/*
- * PartitionManager.java
- * 03.03.26 aho creation
- */
-
-package org.xenoserver.control;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Vector;
-
-/**
- * PartitionManager manages the partitions on the machine. It is a Singleton
- * which automatically initialises itself on first class reference.
- */
-public class PartitionManager {
- /** The proc header string, used to check that this is a suitable proc file. */
- private static final String PROC_TEMPLATE =
- "major minor start_sector num_sectors name";
-
- /** The single PartitionManager reference. */
- public static final PartitionManager IT =
- new PartitionManager(Settings.PARTITIONS_FILE);
-
- /** The list of partitions. */
- private Vector partition_map;
-
- /**
- * Initialize partition manager with source file.
- * Normally we read from /proc/partitions, but we can
- * specify an alternative file for debugging.
- * @param filename The file to read partition data from.
- */
- private PartitionManager(String filename) {
- String str;
- BufferedReader in;
-
- partition_map = new Vector(100, 10);
-
- try {
- in = new BufferedReader(new FileReader(filename));
-
- str = in.readLine(); /* skip headings */
- if (str.length() < PROC_TEMPLATE.length()
- || !str.substring(0, PROC_TEMPLATE.length()).equals(
- PROC_TEMPLATE)) {
- System.err.println("Error: Incorrect /proc/partitions.");
- System.err.println(" Is this Xeno?");
- System.exit(1);
- }
-
- str = in.readLine(); /* skip blank line */
-
- str = in.readLine();
- while (str != null) {
- Partition partition =
- new Partition(
- Integer.parseInt(str.substring( 0, 5).trim()),
- Integer.parseInt(str.substring( 6, 11).trim()),
- Integer.parseInt(str.substring(25, 37).trim())/2,
- Integer.parseInt(str.substring(12, 24).trim()),
- Integer.parseInt(str.substring(25, 37).trim()),
- str.substring(38).trim(),
- false);
-
- partition_map.add(partition);
- str = in.readLine();
- }
- } catch (IOException io) {
- System.err.println(
- "PartitionManager: error reading partition file ["
- + filename
- + "]");
- System.err.println(io);
- }
- }
-
- /**
- * Find a partition with the specified name.
- * @param name The name to search for.
- * @return The partition found, or null if no such partition.
- */
- public Partition getPartition(String name) {
- Partition partition = null;
- for (Enumeration e = partition_map.elements(); e.hasMoreElements();) {
- partition = (Partition) e.nextElement();
- if (partition.getName().equals(name)) {
- return partition;
- }
- }
- return null;
- }
-
- /**
- * Finds the partition that matches the given extent, if any.
- * @param extent The extent to compare to.
- * @return The first matching partition, or null if none.
- */
- public Partition getPartition(Extent extent) {
- Partition partition = null;
- for (Enumeration e = partition_map.elements(); e.hasMoreElements();) {
- partition = (Partition) e.nextElement();
- if (partition.matchesExtent(extent)) {
- return partition;
- }
- }
- return null;
- }
-
- /**
- * Find the ith partition in the partition list.
- * @param i Index number.
- * @return The partition, or null if out of range.
- */
- public Partition getPartition(int i) {
- if ( i >= partition_map.size() ) {
- return null;
- }
- return (Partition) partition_map.elementAt( i );
- }
-
- /**
- * Adds the given partition as a XenoPartition.
- * @param p The partition to add.
- */
- void addXenoPartition(Partition p) {
- for (Enumeration e = partition_map.elements(); e.hasMoreElements();) {
- Partition partition = (Partition) e.nextElement();
- if (partition.identical(p)) {
- partition.makeXeno();
- }
- }
- }
-
- /**
- * Dump the XenoPartition list as XML.
- * @param out Writer to dump to.
- */
- void dumpAsXML(PrintWriter out) {
- out.println("<partitions>");
- for (Enumeration e = partition_map.elements(); e.hasMoreElements();) {
- Partition partition = (Partition) e.nextElement();
- if (partition.isXeno()) {
- partition.dumpAsXML(out);
- }
- }
-
- out.println("</partitions>");
-
- return;
- }
-
- /**
- * @return The number of partitions.
- */
- public int getPartitionCount() {
- return partition_map.size();
- }
-
- /**
- * Get an iterator over all the partitions.
- * @return An iterator over Partition objects.
- */
- public Iterator iterator() {
- return partition_map.iterator();
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-import java.io.File;
-import java.util.StringTokenizer;
-
-/**
- * The Settings class is a repository for global settings such as the IP of
- * the machine and the location of the defaults file.
- */
-public final class Settings {
- /** Filename for the defaults file. */
- public static final String DEFAULTS_FILE =
- System.getProperty("DEFAULTS_FILE", "xenctl.xml");
- /** Path to search for the defaults file. */
- public static final String DEFAULTS_PATH =
- System.getProperty("DEFAULTS_PATH", ".:/etc:/var/lib/xen");
- /** If set, do not call any xi_ commands, just print their command lines. */
- public static final boolean TEST = (System.getProperty("TEST") != null);
- /** Name of xi_helper utility. */
- public static final String XI_HELPER =
- System.getProperty("XI_HELPER", "xi_helper");
- /** File to parse to get partition info. */
- public static final String PARTITIONS_FILE =
- System.getProperty("PARTITIONS_FILE", "/proc/xeno/blkdev_info");
- /** File to load virtual disk state from. */
- public static final String STATE_INPUT_FILE =
- System.getProperty("STATE_INPUT_FILE", "/var/lib/xen/vdstate.xml");
- /** File to save virtual disk state to. */
- public static final String STATE_OUTPUT_FILE =
- System.getProperty("STATE_OUTPUT_FILE", "/var/lib/xen/vdstate.xml");
- /** Size of a sector in bytes. */
- public static final int SECTOR_SIZE =
- Integer.parseInt(System.getProperty("SECTOR_SIZE", "512"));
-
- /**
- * Search for the defaults file in the path configured in DEFAULTS_PATH.
- * @return Reference to the defaults file.
- */
- public static File getDefaultsFile() {
- StringTokenizer tok = new StringTokenizer(DEFAULTS_PATH, ":");
- File result = null;
- File probe;
-
- while (tok.hasMoreTokens()) {
- String probe_dir = tok.nextToken();
- probe = new File(probe_dir, DEFAULTS_FILE);
- if (probe.exists()) {
- result = probe;
- break;
- }
- }
-
- if (result == null) {
- System.err.println(
- "Could not find "
- + DEFAULTS_FILE
- + " in path "
- + DEFAULTS_PATH);
- }
-
- return result;
- }
-}
+++ /dev/null
-package org.xenoserver.control;
-
-/**
- * This utility class expands configuration file patterns.
- */
-public class StringPattern {
- /** The base string for this pattern. */
- private String base;
- /** The base number for this pattern. */
- private int bn;
- /** If true, add the domain number to the base number and append. */
- private boolean addDom;
- /** If true, append the domain number to the base string. */
- private boolean appendDom;
-
- /**
- * Parse a string into a pattern.
- * @param t The pattern string to parse.
- * @return A usable pattern object.
- */
- public static StringPattern parse(String t) {
- StringPattern result = new StringPattern();
- char[] ca = t.toCharArray();
- int idx = 0;
- int len = ca.length;
-
- if (len == 0) {
- result.base = "";
- result.bn = 0;
- result.addDom = false;
- } else if (ca[len - 1] == '+') {
- idx = len - 2;
- if ((idx >= 0) && (ca[idx] >= '0') && (ca[idx] <= '9')) {
- while ((idx >= 0) && (ca[idx] >= '0') && (ca[idx] <= '9')) {
- idx--;
- }
- result.base = t.substring(0, idx + 1);
- result.bn = Integer.parseInt(t.substring(idx + 1, len - 1));
- result.addDom = true;
- } else {
- result.base = t.substring(0, len - 1);
- result.appendDom = true;
- }
- } else {
- result.base = t;
- }
-
- return result;
- }
-
- /**
- * Resolve the pattern for the given domain number.
- * @param domain The domain number to use.
- * @return The expanded pattern for the given domain.
- */
- public String resolve(int domain) {
- if (addDom) {
- return base + (bn + domain);
- } else if (appendDom) {
- return base + domain;
- } else {
- return base;
- }
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return (
- "["
- + base
- + (addDom ? "+" + bn : "")
- + ((addDom || appendDom) ? "+ID" : "")
- + "]");
- }
-
-}
+++ /dev/null
-/*
- * VirtualBlockDevice.java
- * 03.03.27 aho creation
- */
-
-package org.xenoserver.control;
-
-/**
- * A virtual block device; a mapping from a domain-specific number to a virtual
- * disk with associated access mode.
- */
-public class VirtualBlockDevice {
- /** The virtual disk which this block device maps onto. */
- private VirtualDisk vd;
- /** The domain in which this block device exists. */
- private int domain;
- /** The block device number in that domain. */
- private int vbdNum;
- /** The access mode within that domain. */
- private Mode mode;
-
- /**
- * Constructor for VirtualBlockDevice.
- * @param vd The virtual disk to map to.
- * @param domain The domain to create the device in.
- * @param vbdNum The number for the device.
- * @param mode The access mode.
- */
- VirtualBlockDevice(
- VirtualDisk vd,
- int domain,
- int vbdNum,
- Mode mode) {
- this.vd = vd;
- this.domain = domain;
- this.vbdNum = vbdNum;
- this.mode = mode;
- }
-
- /**
- * @return This device's virtual disk.
- */
- public VirtualDisk getVirtualDisk() {
- return vd;
- }
-
- /**
- * @return The domain this device exists in.
- */
- public int getDomain() {
- return domain;
- }
-
- /**
- * @return The device number within its domain.
- */
- public int getVbdNum() {
- return vbdNum;
- }
-
- /**
- * @return This device's access mode.
- */
- public Mode getMode() {
- return mode;
- }
-}
+++ /dev/null
-/*
- * VirtualDisk.java
- * 03.03.26 aho creation
- */
-
-package org.xenoserver.control;
-
-import java.io.PrintWriter;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Vector;
-
-/**
- * A single virtual disk. This may be used by multiple virtual block devices.
- */
-public class VirtualDisk {
- /** The name of this virtual disk. */
- private String name;
- /** The key of this virtual disk (unique). */
- private String key;
- /** The expiry time of this virtual disk, or null for never. */
- private Date expiry;
- /** The extent list for this virtual disk. */
- private Vector extents;
-
- /**
- * Construct a new virtual disk, specifying all parameters.
- * @param name Name of the new disk.
- * @param expiry Expiry time, or null for never.
- * @param key Key for the new disk, or null to autogenerate.
- */
- VirtualDisk(String name, Date expiry, String key) {
- this.name = name;
- if (key == null) {
- this.key = generateKey();
- } else {
- this.key = key;
- }
- this.expiry = expiry;
- extents = new Vector();
- }
-
- /**
- * Construct a new virtual disk, with automatically generated key and no expiry.
- * @param name Name of the new disk.
- */
- VirtualDisk(String name) {
- this(name, null, null);
- }
-
- /**
- * Construct a new virtual disk, with automatically generated key.
- * @param name Name of the new disk.
- * @param expiry Expiry time, or null for never.
- */
- VirtualDisk(String name, Date expiry) {
- this(name, expiry, null);
- }
-
- /**
- * Generate a unique key for this virtual disk.
- * For now, just generate a 10 digit number.
- * @return A unique key.
- */
- private static String generateKey() {
- return Long.toString(
- 1000000000L + (long) (Math.random() * 8999999999L));
- }
-
- /**
- * Add an extent to this disk.
- * @param extent The extent to add.
- */
- void addExtent(Extent extent) {
- extents.add(extent);
- }
-
- /**
- * Remove the first extent from this disk.
- * @return The extent removed, or null if there are no extents.
- */
- Extent removeExtent() {
- Extent e;
-
- if (extents.size() > 0) {
- e = (Extent) extents.remove(0);
- } else {
- e = null;
- }
-
- return e;
- }
-
- /**
- * Form a string suitable for passing into the XenoLinux proc interface mapping
- * the given VBD to this virtual disk.
- * @param vbd The virtual block device to map.
- * @return A XenoLinux /proc string.
- */
- String dumpForXen(VirtualBlockDevice vbd) {
- StringBuffer sb = new StringBuffer();
-
- sb.append(
- "domain:"
- + vbd.getDomain()
- + " "
- + vbd.getMode().toString()
- + " "
- + "segment:"
- + vbd.getVbdNum()
- + " "
- + "key: "
- + this.getKey()
- + " "
- + "extents:"
- + extents.size()
- + " ");
- for (int loop = 0; loop < extents.size(); loop++) {
- Extent e = (Extent) extents.get(loop);
- sb.append(
- "(disk:"
- + e.getDisk()
- + " "
- + "offset:"
- + e.getOffset()
- + " "
- + "size:"
- + e.getSize()
- + ")");
- }
- return sb.toString();
- }
-
- /**
- * Dump the virtual disk as XML.
- * @param out The writer to dump to.
- */
- void dumpAsXML(PrintWriter out) {
- out.println(" <virtual_disk>");
- out.println(" <name>" + name + "</name>");
- out.println(" <key>" + key + "</key>");
- if (expiry == null) {
- out.println(" <expiry>0</expiry>");
- } else {
- out.println(" <expiry>" + expiry.getTime() + "</expiry>");
- }
- out.println(" <extents>");
- for (int loop = 0; loop < extents.size(); loop++) {
- Extent e = (Extent) extents.get(loop);
- out.println(" <extent>");
- out.println(" <disk>" + e.getDisk() + "</disk>");
- out.println(" <size>" + e.getSize() + "</size>");
- out.println(" <offset>" + e.getOffset() + "</offset>");
- out.println(" </extent>");
- }
- out.println(" </extents>");
- out.println(" </virtual_disk>");
-
- return;
- }
-
- /**
- * Add a partition as a XenoPartition.
- * Chop the partition in to extents and add them to this virtual disk.
- * @param partition The partition to add.
- * @param extentSize The number of sectors to use for each extent.
- */
- void addPartition(Partition partition, long extentSize) {
- int loop;
-
- for (loop = 0; loop < partition.getNumSects() / extentSize; loop++) {
- Extent extent =
- new Extent(
- partition.getDisk(),
- partition.getStartSect() + (extentSize * loop),
- extentSize);
-
- addExtent(extent);
- }
- }
-
- /**
- * @return The name of this virtual disk.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @return The key of this virtual disk.
- */
- public String getKey() {
- return key;
- }
-
- /**
- * @return The expiry time of this virtual disk.
- */
- public Date getExpiry() {
- return expiry;
- }
-
- /**
- * @return The number of extents in this virtual disk.
- */
- public int getExtentCount() {
- return extents.size();
- }
-
- /**
- * @return Total size of this virtual disk in sectors.
- */
- public long getSize() {
- long size = 0;
- Iterator i = extents.iterator();
- while (i.hasNext()) {
- size += ((Extent) i.next()).getSize();
- }
- return size;
- }
-
- /**
- * @return An iterator over all extents in the disk.
- */
- public Iterator extents() {
- return extents.iterator();
- }
-
- /**
- * Reset the expiry time for this virtual disk.
- * @param expiry The new expiry time, or null for never.
- */
- void refreshExpiry(Date expiry) {
- this.expiry = expiry;
- }
-}
+++ /dev/null
-/*
- * VirtualDiskManager.java
- * 03.03.26 aho creation
- */
-
-package org.xenoserver.control;
-
-import java.io.PrintWriter;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-
-/**
- * VirtualDiskManager manages the list of virtual disks on the machine. It is
- * a Singleton which automatically initialises itself on first class reference.
- */
-public class VirtualDiskManager {
- /** The single VDM reference. */
- public static final VirtualDiskManager IT = new VirtualDiskManager();
- /** The free-space disk. */
- private VirtualDisk freeDisk;
- /** The map of keys to virtual disks. */
- private LinkedHashMap virtualDisks = new LinkedHashMap(100);
-
- /**
- * VDM constructor, private as it's a singleton.
- */
- private VirtualDiskManager() {
- freeDisk = new VirtualDisk("free");
- }
-
- /**
- * Get the virtual disk with the specified key.
- * @param key The key to look for.
- * @return The virtual disk, or null if not found.
- */
- public VirtualDisk getVirtualDisk(String key) {
- return ((VirtualDisk) virtualDisks.get(key));
- }
-
- /**
- * Add a new partition to the free space list in the disk manager.
- * @param partition The partition to add.
- * @param chunkSize The chunk size to split the partition into, in sectors.
- */
- void addPartition(Partition partition, long chunkSize) {
- freeDisk.addPartition(partition, chunkSize);
- }
-
- /**
- * Create a new virtual disk.
- * @param name The disk name to use.
- * @param size The number of sectors to allocate.
- * @param expiry The expiry time, or null for never.
- * @return null if not enough space is available
- */
- VirtualDisk createVirtualDisk(String name, long size, Date expiry) {
- if (freeDisk.getSize() < size) {
- return null;
- }
-
- VirtualDisk vd = new VirtualDisk(name, expiry);
-
- while (size > 0) {
- Extent e;
-
- e = freeDisk.removeExtent();
- if (e == null) {
- return null;
- }
- size -= e.getSize();
- vd.addExtent(e);
- }
-
- insertVirtualDisk(vd);
-
- return vd;
- }
-
- /**
- * Delete a virtual disk, and put its extents back into the free pool.
- * @param key The key of the disk to delete.
- */
- void deleteVirtualDisk(String key) {
- VirtualDisk vd;
-
- vd = (VirtualDisk) virtualDisks.get(key);
- if (vd != null) {
- Extent e;
-
- virtualDisks.remove(key);
-
- e = vd.removeExtent();
- while (e != null) {
- freeDisk.addExtent(e);
- e = vd.removeExtent();
- }
- }
- }
-
- /**
- * Insert a new virtual disk into the map.
- * @param vd The disk to insert.
- */
- void insertVirtualDisk(VirtualDisk vd) {
- virtualDisks.put(vd.getKey(), vd);
- }
-
- /**
- * Hash a virtual block device.
- * @param domain The VBD's domain.
- * @param vbdNum The VBD's number within the domain.
- * @return A suitable hash key.
- */
- Object hashVBD(int domain, int vbdNum) {
- return new Integer(domain * 16 + vbdNum);
- }
-
- /**
- * Set a new free disk.
- * @param vd The free disk to set.
- */
- void setFreeDisk(VirtualDisk vd) {
- freeDisk = vd;
- }
-
- /**
- * Dump the data in the VirtualDiskManager in XML form.
- * @param out The output writer to dump to.
- */
- void dumpAsXML(PrintWriter out) {
- out.println("<free>");
- freeDisk.dumpAsXML(out);
- out.println("</free>");
- out.println("<virtual_disks>");
- Iterator i = virtualDisks.values().iterator();
- while (i.hasNext()) {
- VirtualDisk vd = (VirtualDisk) i.next();
- vd.dumpAsXML(out);
- }
- out.println("</virtual_disks>");
- }
-
- /**
- * @return The free disk.
- */
- public VirtualDisk getFreeDisk() {
- return freeDisk;
- }
-
- /**
- * @return An iterator over the virtual disks.
- */
- public Iterator getVirtualDisks() {
- return virtualDisks.values().iterator();
- }
-}
+++ /dev/null
-/*
- * XML.java
- * 03.03.26 aho creation
- */
-
-package org.xenoserver.control;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Utility class for loading and saving state through XML files.
- */
-public class XML {
- /** The document we are reading/writing. */
- private static Document document = null;
-
- /**
- * Save the state of the managers to the configuration file given.
- * @param pm The PartitionManager to save.
- * @param vdm The VirtualDiskManager to save.
- * @param filename The configuration filename to save to.
- */
- public static void saveState(
- PartitionManager pm,
- VirtualDiskManager vdm,
- String filename) {
- PrintWriter out;
-
- try {
- out = new PrintWriter(new BufferedWriter(new FileWriter(filename)));
- } catch (IOException e) {
- System.err.println("XML.dump_state error [" + filename + "]");
- System.err.println(e);
- return;
- }
-
- out.println("<?xml version=\"1.0\"?>");
- out.println("<vdmanager>");
- pm.dumpAsXML(out);
- vdm.dumpAsXML(out);
- out.println("</vdmanager>");
-
- out.close();
- return;
- }
-
- /**
- * Load the state of the managers from the given configuration file.
- * @param pm The PartitionManager to load.
- * @param vdm The VirtualDomainManager to load.
- * @param filename The filename to read the configuration from.
- */
- public static void loadState(
- PartitionManager pm,
- VirtualDiskManager vdm,
- String filename) {
- if (document == null) {
- loadFile(filename);
- }
-
- XMLHelper.parse(pm, vdm, document);
- }
-
- /**
- * Load an XML file and parse it into a Document.
- * @param filename The file to load.
- */
- private static void loadFile(String filename) {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-
- try {
- File file = new File(filename);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- document = builder.parse(file);
- } catch (SAXParseException spe) /* error generated by parser */ {
- System.err.println(
- "xml parser exception on line "
- + spe.getLineNumber()
- + " for uri "
- + spe.getSystemId());
- System.err.println(spe.getMessage());
-
- Exception x = spe;
- if (spe.getException() != null) {
- x = spe.getException();
- }
- x.printStackTrace();
- System.exit(1);
- } catch (SAXException sxe) {
- Exception e = sxe;
- if (sxe.getException() != null) {
- e = sxe.getException();
- }
- e.printStackTrace();
- System.exit(1);
- } catch (ParserConfigurationException pce) {
- pce.printStackTrace();
- } catch (FileNotFoundException fnfe) {
- System.err.println(
- "warning: state file not found [" + filename + "]");
- } catch (IOException ioe) {
- ioe.printStackTrace();
- }
- return;
- }
-}
+++ /dev/null
-/*
- * XMLHelper.java
- * 03.03.27 aho creation
- */
-
-package org.xenoserver.control;
-
-import java.util.Date;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * XMLHelper contains helper methods used to parse the XML state files.
- */
-class XMLHelper {
- /**
- * Find a subnode with the specified name.
- * @param name Name to look for.
- * @param node Node from which to start search.
- * @return The first subnode found, or null if none.
- */
- private static Node getSubNode(String name, Node node) {
- if (node.getNodeType() != Node.ELEMENT_NODE) {
- System.err.println("Error: Search node not of element type");
- return null;
- }
-
- if (!node.hasChildNodes()) {
- return null;
- }
-
- NodeList list = node.getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- Node subnode = list.item(i);
- if (subnode.getNodeType() == Node.ELEMENT_NODE) {
- if (subnode.getNodeName() == name) {
- return subnode;
- }
- }
- }
- return null;
- }
-
- /**
- * Get all the text of a given node.
- * @param node The node to examine.
- * @return The node's text.
- */
- private static String getText(Node node) {
- StringBuffer result = new StringBuffer();
- if (node == null || !node.hasChildNodes()) {
- return "";
- }
-
- NodeList list = node.getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- Node subnode = list.item(i);
- if (subnode.getNodeType() == Node.TEXT_NODE) {
- result.append(subnode.getNodeValue());
- }
- }
- return result.toString();
- }
-
- /**
- * Parse the given configuration document and configure the managers.
- * @param pm PartitionManager instance to configure.
- * @param vdm VirtualDomainManager instance to configure.
- * @param document Document to parse.
- */
- static void parse(
- PartitionManager pm,
- VirtualDiskManager vdm,
- Document document) {
- if (document == null) {
- return;
- }
-
- /* parse partitions */
- parsePartitions(pm, document.getElementsByTagName("partition"));
-
- /* parse virtual disks */
- NodeList list = document.getElementsByTagName("virtual_disk");
- for (int i = 0; i < list.getLength(); i++) {
- Node subnode = list.item(i);
- String parent = subnode.getParentNode().getNodeName();
- VirtualDisk vd = parseVirtualDisk(subnode);
-
- if (parent.equals("free")) {
- vdm.setFreeDisk(vd);
- } else if (parent.equals("virtual_disks")) {
- vdm.insertVirtualDisk(vd);
- } else {
- System.out.println(
- "XML parse error: unknown parent for virtual_disk "
- + "["
- + parent
- + "]");
- }
- }
- }
-
- /**
- * Parse a node representing a virtual disk.
- * @param node The node to parse.
- * @return The VirtualDisk this node represents.
- */
- private static VirtualDisk parseVirtualDisk(Node node) {
- VirtualDisk vd;
- Date date = new Date();
- NodeList list;
-
- long timestamp =
- Long.parseLong(
- XMLHelper.getText(XMLHelper.getSubNode("expiry", node)));
- if (timestamp == 0) {
- date = null;
- } else {
- date.setTime(timestamp);
- }
- vd =
- new VirtualDisk(
- XMLHelper.getText(XMLHelper.getSubNode("name", node)),
- date,
- XMLHelper.getText(XMLHelper.getSubNode("key", node)));
-
- list = XMLHelper.getSubNode("extents", node).getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- Node enode = list.item(i);
-
- if (enode.getNodeType() == Node.ELEMENT_NODE
- && enode.getNodeName().equals("extent")) {
- Extent extent =
- new Extent(
- Integer.parseInt(
- XMLHelper.getText(
- XMLHelper.getSubNode("disk", enode))),
- Long.parseLong(
- XMLHelper.getText(
- XMLHelper.getSubNode("offset", enode))),
- Long.parseLong(
- XMLHelper.getText(
- XMLHelper.getSubNode("size", enode))));
-
- vd.addExtent(extent);
- }
- }
-
- return vd;
- }
-
- /**
- * Parse a list of partition nodes.
- * @param pm The partition manager to configure.
- * @param nl The list of partition nodes.
- */
- private static void parsePartitions(PartitionManager pm, NodeList nl) {
- Partition partition;
-
- for (int loop = 0; loop < nl.getLength(); loop++) {
- Node node = nl.item(loop);
-
- partition =
- new Partition(
- Integer.parseInt(
- XMLHelper.getText(XMLHelper.getSubNode("major", node))),
- Integer.parseInt(
- XMLHelper.getText(XMLHelper.getSubNode("minor", node))),
- Integer.parseInt(
- XMLHelper.getText(
- XMLHelper.getSubNode("blocks", node))),
- Integer.parseInt(
- XMLHelper.getText(
- XMLHelper.getSubNode("start_sect", node))),
- Integer.parseInt(
- XMLHelper.getText(
- XMLHelper.getSubNode("nr_sects", node))),
- XMLHelper.getText(XMLHelper.getSubNode("name", node)),
- true);
-
- pm.addXenoPartition(partition);
- }
- }
-}
+++ /dev/null
-/*
- * RootBean.java
- * 03.05.05 aho creation
- */
-
-package org.xenoserver.web;
-
-import javax.servlet.http.HttpSessionBindingEvent;
-import javax.servlet.http.HttpSessionBindingListener;
-
-import org.xenoserver.control.PartitionManager;
-import org.xenoserver.control.Settings;
-import org.xenoserver.control.VirtualDiskManager;
-import org.xenoserver.control.XML;
-
-public class RootBean implements HttpSessionBindingListener {
- PartitionManager pm;
- VirtualDiskManager vdm;
-
- public RootBean() {
- valueBound(null);
- }
-
- public void valueBound(HttpSessionBindingEvent event) {
- pm = PartitionManager.IT;
- vdm = VirtualDiskManager.IT;
- XML.loadState(pm, vdm, Settings.STATE_INPUT_FILE);
- }
-
- public void valueUnbound(HttpSessionBindingEvent event) {
- doFlushState();
- }
-
- public PartitionManager pm() {
- return pm;
- }
-
- public VirtualDiskManager vdm() {
- return vdm;
- }
-
- public void doFlushState() {
- XML.saveState(pm, vdm, Settings.STATE_OUTPUT_FILE);
- }
-}
+++ /dev/null
-/*
- * SystemConfigurationBean.java
- * 03.05.06 aho creation
- */
-
-package org.xenoserver.web;
-
-import org.xenoserver.control.Defaults;
-
-public class SystemConfigurationBean {
- private Defaults defaults;
-
- public SystemConfigurationBean() {
- defaults = new Defaults();
- }
-
- public Defaults getDefaults() {
- return defaults;
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<!DOCTYPE web-app PUBLIC
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-
-<web-app>
- <display-name>Xen Control</display-name>
- <description>
- Copyright 2003, University of Cambridge Computer Laboratory
- This is version 1.0-beta of the Xen control software.
- </description>
- <welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
-
- <session-config>
- <session-timeout>30</session-timeout>
- </session-config>
-
-</web-app>
+++ /dev/null
-About
-SECTION&XenoServers
-
-<!-- content -->
-<img src="img/pixel.gif" class="block" width="1" height="12" alt="">
-<table cellpadding="0" cellspacing="0" border="0" summary="page content">
-<tbody><tr>
- <td width="250" valign="top" align="right">
- <a href="http://www.cl.cam.ac.uk/xeno/"><img width="191" heigth="65" src="img/xeno.gif" border="0"></a>
-
-<table cellpadding="0" cellspacing="0" border="0" align="right">
-<tbody><tr>
- <td><img src="img/pixel.gif" class="block" width="20" height="1" alt=""></td>
-</tr>
-<tr>
- <td colspan="3"><img src="img/pixel.gif" class="block" width="1" height="10" alt=""></td>
-</tr>
-<tr>
- <td align="right">
- <table width="180" ><tbody><tr><td><p align="right">
-The XenoServer project aims to build a public infrastructure for wide-area distributed computing.
-</p>
- </td></tr></tbody></table></td>
-<td><img src="img/pixel.gif" class="block" width="10" height="1" alt=""></td>
-</tr>
-</tbody></table>
-</td>
-<td bgcolor="#666666" width="2"><img src="img/pixel.gif" class="block" width="2" height="50" alt=""></td>
-<td width="20"><img src="img/pixel.gif" class="block" width="20" height="1" alt=""></td>
-<td valign="top">
-
-<!-- main navigation -->
-<table cellpadding="0" cellspacing="0" border="0">
-
-<tbody><tr><td><b>Overview</b><td></tr>
-<tr>
- <td>
-The Xenoserver project is building a public infrastructure for wide-area distributed computing. We envisage a world in which Xenoserver execution platforms will be scattered across the globe and available for any member of the public to submit code for execution. Crucially, the sponsor of the code will be billed for all the resources used or reserved during the course of execution. This will serve to encourage load balancing, limit congestion, and hopefully even make the platform self-financing.
-<p>
-A global infrastructure such as we propose is essential to address the fundamental problem of communication latency. By enabling principles to run programs at points throughout the network they can ensure that their code executes close to the entities with which it needs to interact. As well as reducing latency this can be used to avoid network bottlenecks, to reduce long-haul network charges and to provide a platform over which code provided by transiently-connected mobile devices can maintain a network presence.
-<p>
-Our approach is distinguished from existing work on mobile agents, execution platforms, code hosting and the like by two principles:
-<p>
-<b>Tackling difficult problems at the same time.</b> Acceptable designs for execution environments, resource management, resource discovery, authentication, privacy, charging, billing, payment and auditing are all crucial to the success of our platform as an infrastructure service open to and accepted by the public. Existing work has tackled individual subsets of these problems, but tensions between the issues concerned mean that solutions proficient in some dimension are lacking in another.
-<p>
-<b>No brave new world.</b> Our platform will host applications written in today's programming languages against existing APIs -- and, we believe, those written with tomorrow's languages and libraries. We do not want to mandate a particular code distribution format or a particular middleware toolkit for distributed programming.
-</td>
-</tr>
-
-<tr> <!-- blank white space -->
- <td><img src="img/pixel.gif" class="block" width="1" height="10" alt=""></td>
-</tr>
-
-<tr> <!-- grey line -->
- <td bgcolor="#cccccc"><img src="img/pixel.gif" class="block" width="1" height="2" alt=""></td>
-</tr>
-
-<tr> <!-- blank white space -->
- <td><img src="img/pixel.gif" class="block" width="1" height="10" alt=""></td>
-</tr>
-
-<tr> <!-- list of menu items -->
- <td nowrap="nowrap">
- <a href="http://www.cl.cam.ac.uk/Research/SRG/netos/xeno/general-xeno.pdf" class="homemenu">Project Overview Document</a><br>
- </td>
-</tr>
-</tbody></table>
-</td>
-</tr>
-</tbody></table>
-<!-- end content -->
+++ /dev/null
-Delete Domain
-SECTION&XenoServers
-BREADCRUMB&Domain Manager&dom.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&dommenu.tmpl
-<td valign="top">
-
-<form method="post" action="dom-delr.jsp">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-<tr><td>
-<%
- CommandDomainList list = new CommandDomainList(sc.getDefaults());
- String output = list.executeWeb();
- Domain domains[] = list.domains();
- if (output != null)
- {
-%>
-<%= output %>
-<%
- } else {
-%>
-
-<table cellpadding="2" cellspacing="0" border="0">
-<tbody>
- <tr class="vdh"><td></td><td>domain<br>id</td><td>processor</td><td>has<br>cpu</td><td>state</td><td>mcu<br>advance</td><td>total<br>pages</td><td>name</td></tr>
- <%
- for (int loop = 0; loop < domains.length; loop++)
- {
- %>
- <tr class="vdt">
- <td><input type="checkbox" name="dom" value="<%= domains[loop].id %>"></td>
- <td align="center"><%= domains[loop].id %></td>
- <td align="center"><%= domains[loop].processor %></td>
- <td align="center"><%= domains[loop].cpu %> </td>
- <td><%= domains[loop].state %> </td>
- <td align="center"><%= domains[loop].mcu %> </td>
- <td align="center"><%= domains[loop].pages %> </td>
- <td><%= domains[loop].name %> </td>
- </tr>
- <%
- }
- %>
-
-</tbody>
-</table>
-</td></tr>
-
-<%
- }
-%>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr><td>
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-
-<tr>
- <td></td>
- <td class="menuheader">force immediate destruction?</td>
-</tr>
-<tr>
- <td> <input type="radio" name="force" value="false" checked></td>
- <td> don't force </td>
-</tr>
-<tr>
- <td> <input type="radio" name="force" value="true"></td>
- <td> force </td>
-</tr>
-</tbody>
-</table>
-</td></tr>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr>
- <td><input type="submit" name="action" value="delete domain"></td>
-</tr>
-</tbody>
-</table>
-</form>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Delete Domain
-SECTION&XenoServers
-BREADCRUMB&Domain Manager&dom.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&dommenu.tmpl
-<td valign="top">
-
-
-<b>Delete Domain Results</b>
-<br>
-
-<%
- HttpServletRequestWrapper hsrw = new HttpServletRequestWrapper(request);
- Defaults d = sc.getDefaults();
-
- String domains[] = hsrw.getParameterValues("dom");
- boolean force = hsrw.getParameter("force").equals("true");
-
- if (domains == null || domains.length == 0)
- {
-%>
-Error: no domain specified.<br>
-<%
- }
- else
- {
- for (int i = 0; i < domains.length; i++)
- {
-%>
-result <%= domains[i] %> =
- <%= new CommandDomainDestroy(d, Integer.parseInt(domains[i]),
- force).executeWeb() %> <br>
-<%
- }
- }
-%>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Domain List
-SECTION&XenoServers
-BREADCRUMB&Domain Manager&dom.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&dommenu.tmpl
-<td valign="top">
-
-<%
- CommandDomainList list = new CommandDomainList(sc.getDefaults());
- String output = list.executeWeb();
- Domain domains[] = list.domains();
- if (output != null)
- {
-%>
-<%= output %>
-<%
- } else {
-%>
-
-<table cellpadding="2" cellspacing="0" border="0">
-<tbody>
- <tr class="vdh"><td>domain<br>id</td><td>processor</td><td>has<br>cpu</td><td>state</td><td>mcu<br>advance</td><td>total<br>pages</td><td>name</td></tr>
- <%
- /* assert: domains != null, otherwise, where is the servlet engine? */
- for (int loop = 0; loop < domains.length; loop++)
- {
- %>
- <tr>
- <td align="center"><%= domains[loop].id %></td>
- <td align="center"><%= domains[loop].processor %></td>
- <td align="center"><%= domains[loop].cpu %> </td>
- <td><%= domains[loop].state %> </td>
- <td align="center"><%= domains[loop].mcu %> </td>
- <td align="center"><%= domains[loop].pages %> </td>
- <td><%= domains[loop].name %> </td>
- </tr>
- <%
- }
- %>
-</tbody>
-</table>
-<%
- }
-%>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Create New Domain
-SECTION&XenoServers
-BREADCRUMB&Domain Manager&dom.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&dommenu.tmpl
-<td valign="top">
-
-<form method="post" action="dom-newr.jsp">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-<tr>
- <td width="10"></td>
- <td></td>
- <td></td>
- <td width="7"></td>
- <td></td>
-</tr>
-
-<tr>
- <td></td>
- <td class="block" colspan=4><b>Create A New Domain</b></td>
-</tr>
-
-##WHITESPACE## ##GREYLINE14## ##WHITESPACE##
-
-<%
- Defaults d = sc.getDefaults();
-
- if (d == null)
- {
-%>
- <b>ACK Defaults IS NULL</b>
-<%
- }
-%>
-
-<tr>
- <td></td>
- <td class="block" colspan=4>Domain Name</td>
-</tr>
-<tr>
- <td></td> <td></td> <td></td> <td></td>
- <td> <input type="text" size="16" name="name" value="<%= d.domainName %>">
- </td>
-</tr>
-
-##WHITESPACE## ##GREYLINE14## ##WHITESPACE##
-
-<tr>
- <td></td>
- <td class="block" colspan=4>Memory Size</td>
-</tr>
-<tr>
- <td></td> <td></td> <td></td> <td></td>
- <td>
- <input type="text" size="5" name="size" value="<%= d.domainSizeKB %>"> KB
- </td>
-</tr>
-
-##WHITESPACE## ##GREYLINE14## ##WHITESPACE##
-
-<tr>
- <td></td>
- <td class="block" colspan=4>Kernel Image</td>
-</tr>
-<tr>
- <td></td>
- <td colspan=2 align="right">path</td>
- <td></td>
- <td>
- <input type="text" size="40" name="image" value="<%= d.domainImage %>">
- </td>
-</tr>
-
-##WHITESPACE## ##GREYLINE14## ##WHITESPACE##
-
-<tr>
- <td></td>
- <td class="block" colspan=4>IP Config</td>
-</tr>
-<tr>
- <td></td> <td></td>
- <td class="block" align="right">VIFs</td>
- <td></td>
- <td>
- <input type="text" size="4" name="vifs" value="<%= d.domainVIFs %>">
- </td>
-</tr>
-<tr>
- <td></td> <td></td>
- <td class="block" align="right">IP address</td>
- <td></td>
- <td> <input type="text" size="15" name="ip" value="<%= d.nwIP %>"> </td>
-</tr>
-<tr>
- <td></td> <td></td>
- <td class="block" align="right">Gateway</td>
- <td></td>
- <td> <input type="text" size="15" name="gw" value="<%= d.nwGateway %>"> </td>
-</tr>
-<tr>
- <td></td> <td></td>
- <td class="block" align="right">Netmask</td>
- <td></td>
- <td> <input type="text" size="15" name="mask" value="<%= d.nwMask %>"> </td>
-</tr>
-
-##WHITESPACE## ##GREYLINE14## ##WHITESPACE##
-
-<tr>
- <td></td>
- <td class="block" colspan=2>Root File System</td>
-</tr>
-
-##WHITESPACE##
-
-<tr>
- <td></td>
- <td align="right">NFS<input type="radio" checked name="root" value="nfs"></td>
- <td align="right">path</td>
- <td></td>
- <td>
- <input type="text" size="40" name="nfsroot" value="<%= d.nwNFSRoot %>">
- </td>
-</tr>
-<tr>
- <td></td> <td></td>
- <td align="right">server</td>
- <td></td>
- <td>
- <input type="text" size="15" name="nfsserver" value="<%= d.nwNFSServer%>">
- </td>
-</tr>
- ##WHITESPACE##
-<tr>
- <td></td>
- <td align="right">ramdisk<input type="radio" name="root" value="ram"></td>
- <td align="right">path</td>
- <td></td>
- <td>
- <input type="text" size="40" name="rd" value="<%= d.domainInitRD %>">
- </td>
-</tr>
- ##WHITESPACE##
-<tr>
- <td></td>
- <td align="right">physical disk<input type="radio" name="root" value="pdisk"></td>
- <td align="right">path</td>
- <td></td>
- <td><input type="text" size="40" name="pdisk" value="/dev/sda8"></td>
-</tr>
-<tr>
- <td></td>
- <td align="right">virtual disk<input type="radio" name="root" value="vdisk"></td>
- <td align="right">path</td>
- <td></td>
- <td><input type="text" size="40" name="vdisk" value="/dev/xvda1"></td>
-</tr>
-
-##WHITESPACE## ##GREYLINE14## ##WHITESPACE##
-
-<tr>
- <td></td>
- <td class="block" colspan=4>Extra Arguments</td>
-</tr>
-<tr>
- <td></td>
- <td colspan=2 align="right"></td>
- <td></td>
- <td> <input type="text" size="40" name="args" value="<%= d.args %>"> </td>
-</tr>
-
-
-##WHITESPACE## ##GREYLINE14## ##WHITESPACE##
-
-<tr>
- <td></td>
- <td><input type="submit" value="create domain"></td>
-</tr>
-
-</tbody>
-</table>
-</form>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Create New Domain
-SECTION&XenoServers
-BREADCRUMB&Domain Manager&dom.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&dommenu.tmpl
-<td valign="top">
-
-<b>Create Domain Results</b>
-<br>
-
-<%
- HttpServletRequestWrapper hsrw = new HttpServletRequestWrapper(request);
- Defaults d = sc.getDefaults();
- String root_device = hsrw.getParameter("root");
-
- String nfsroot = null;
- String nfsserver = null;
- String rd = null;
- String disk = null;
-
- if (root_device.equals("nfs"))
- {
- nfsroot = hsrw.getParameter("nfsroot");
- nfsserver = hsrw.getParameter("nfsserver");
- disk = "/dev/nfs";
- }
- else if (root_device.equals("ram"))
- {
- nfsserver = hsrw.getParameter("nfsserver");
- rd = hsrw.getParameter("rd");
- }
- else if (root_device.equals("pdisk"))
- {
- nfsserver = hsrw.getParameter("nfsserver");
- disk = hsrw.getParameter("pdisk");
- }
- else if (root_device.equals("vdisk"))
- {
- nfsserver = hsrw.getParameter("nfsserver");
- disk = hsrw.getParameter("vdisk");
- }
-
-%>
-name = <%= hsrw.getParameter("name") %>
-<br>
-size = <%= hsrw.getParameter("size") %>
-<br>
-image = <%= hsrw.getParameter("image") %>
-<br>
-initrd = <%= rd %>
-<br>
-vifs = <%= hsrw.getParameter("vifs") %>
-<br>
-bargs = <%= hsrw.getParameter("args") %>
-<br>
-nfs_root_path = <%= nfsroot %>
-<br>
-nw_ip = <%= hsrw.getParameter("ip") %>
-<br>
-nw_gw = <%= hsrw.getParameter("gw") %>
-<br>
-nw_mask = <%= hsrw.getParameter("mask") %>
-<br>
-nw_nfs_server = <%= nfsserver %>
-<br>
-nw_host = <%= hsrw.getParameter("hostname") %>
-<br>
-root = <%= disk %>
-<br>
-output = <br>
-<%
- CommandDomainNew command_new = new CommandDomainNew(d,
- hsrw.getParameter("name"),
- Integer.parseInt(hsrw.getParameter("size")),
- hsrw.getParameter("image"),
- rd,
- Integer.parseInt(hsrw.getParameter("vifs")),
- hsrw.getParameter("args"),
- disk,
- nfsroot,
- hsrw.getParameter("ip"),
- hsrw.getParameter("gw"),
- hsrw.getParameter("mask"),
- nfsserver,
- hsrw.getParameter("hostname"));
- String oneline = command_new.executeWeb();
- if ( oneline != null ) {
-%>
-<%= oneline %><br>
-<%
- } else {
- String[] output = command_new.output();
- for (int i = 0; i < output.length; i++) {
-%>
-<%= output[i] %><br>
-<%
- }
- }
-%>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Start Domain
-SECTION&XenoServers
-BREADCRUMB&Domain Manager&dom.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&dommenu.tmpl
-<td valign="top">
-
-<form method="post" action="dom-star.jsp">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-<tr><td>
-<%
- CommandDomainList list = new CommandDomainList(sc.getDefaults());
- String output = list.executeWeb();
- Domain domains[] = list.domains();
- if (output != null)
- {
-%>
-<%= output %>
-<%
- } else {
-%>
-
-<table cellpadding="2" cellspacing="0" border="0">
-<tbody>
- <tr class="vdh"><td></td><td>domain<br>id</td><td>processor</td><td>has<br>cpu</td><td>state</td><td>mcu<br>advance</td><td>total<br>pages</td><td>name</td></tr>
- <%
- for (int loop = 0; loop < domains.length; loop++)
- {
- %>
- <tr class="vdt">
- <td><input type="checkbox" name="dom" value="<%= domains[loop].id %>"></td>
- <td align="center"><%= domains[loop].id %></td>
- <td align="center"><%= domains[loop].processor %></td>
- <td align="center"><%= domains[loop].cpu %> </td>
- <td><%= domains[loop].state %> </td>
- <td align="center"><%= domains[loop].mcu %> </td>
- <td align="center"><%= domains[loop].pages %> </td>
- <td><%= domains[loop].name %> </td>
- </tr>
- <%
- }
- %>
-
-</tbody>
-</table>
-</td></tr>
-<%
- }
-%>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr>
- <td><input type="submit" name="action" value="start domain"></td>
-</tr>
-</tbody>
-</table>
-</form>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Start Domain
-SECTION&XenoServers
-BREADCRUMB&Domain Manager&dom.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&dommenu.tmpl
-<td valign="top">
-
-
-<b>Start Domain Results</b>
-<br>
-
-<%
- HttpServletRequestWrapper hsrw = new HttpServletRequestWrapper(request);
- Defaults d = sc.getDefaults();
-
- String domains[] = hsrw.getParameterValues("dom");
-
- if (domains == null || domains.length == 0)
- {
-%>
-Error: no domain specified.<br>
-<%
- }
- else
- {
- for (int i = 0; i < domains.length; i++)
- {
-%>
-result <%= domains[i] %> =
-<%= new CommandDomainStart(d, Integer.parseInt(domains[i])).executeWeb() %><br>
-<%
- }
- }
-%>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Stop Domain
-SECTION&XenoServers
-BREADCRUMB&Domain Manager&dom.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&dommenu.tmpl
-<td valign="top">
-
-<form method="post" action="dom-stpr.jsp">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-<tr><td>
-<%
- CommandDomainList list = new CommandDomainList(sc.getDefaults());
- String output = list.executeWeb();
- Domain domains[] = list.domains();
- if (output != null)
- {
-%>
-<%= output %>
-<%
- } else {
-%>
-
-<table cellpadding="2" cellspacing="0" border="0">
-<tbody>
- <tr class="vdh"><td></td><td>domain<br>id</td><td>processor</td><td>has<br>cpu</td><td>state</td><td>mcu<br>advance</td><td>total<br>pages</td><td>name</td></tr>
- <%
- for (int loop = 0; loop < domains.length; loop++)
- {
- %>
- <tr class="vdt">
- <td><input type="checkbox" name="dom" value="<%= domains[loop].id %>"></td>
- <td align="center"><%= domains[loop].id %></td>
- <td align="center"><%= domains[loop].processor %></td>
- <td align="center"><%= domains[loop].cpu %> </td>
- <td><%= domains[loop].state %> </td>
- <td align="center"><%= domains[loop].mcu %> </td>
- <td align="center"><%= domains[loop].pages %> </td>
- <td><%= domains[loop].name %> </td>
- </tr>
- <%
- }
- %>
-
-</tbody>
-</table>
-</td></tr>
-<%
- }
-%>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr>
- <td><input type="submit" name="action" value="stop domain"></td>
-</tr>
-</tbody>
-</table>
-</form>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Stop Domain
-SECTION&XenoServers
-BREADCRUMB&Domain Manager&dom.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&dommenu.tmpl
-<td valign="top">
-
-
-<b>Stop Domain Results</b>
-<br>
-
-<%
- HttpServletRequestWrapper hsrw = new HttpServletRequestWrapper(request);
- Defaults d = sc.getDefaults();
-
- String domains[] = hsrw.getParameterValues("dom");
-
- if (domains == null || domains.length == 0)
- {
-%>
-Error: no domain specified.<br>
-<%
- }
- else
- {
- for (int i = 0; i < domains.length; i++)
- {
-%>
-result <%= domains[i] %> =
-<%= new CommandDomainStop(d, Integer.parseInt(domains[i])).executeWeb() %><br>
-<%
- }
- }
-%>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Domain Manager
-SECTION&XenoServers
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&dommenu.tmpl
-<td valign="top">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-<%
- Defaults d = sc.getDefaults();
-%>
- <tr><td nowrap="nowrap">Domain Manager</td></tr>
- <tr><td></td></tr>
-<!--
- <tr><td><%= d.xiToolsDir %></td></tr>
--->
-</tbody>
-</table>
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-<td width="10" valign="top" align="right"></td>
-
-<td valign="top">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-<tr>
- <td class="menuheader" width="100">Domains</td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="dom-lis.jsp">List</a></td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="dom-new.jsp">New</a></td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="dom-sta.jsp">Start</a></td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="dom-stp.jsp">Stop</a></td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="dom-del.jsp">Delete</a></td>
-</tr>
-
-</tbody>
-</table>
-</td>
-
-<td width="5" valign="top" align="right"></td>
-
-<td bgcolor="#666666" width="2"><img src="img/pixel.gif" class="block" width="2" height="50"></td>
-
-<td width="15" valign="top" align="right"></td>
+++ /dev/null
-Help
-SECTION&XenoServers
-
-<!-- content -->
-<img src="img/pixel.gif" class="block" width="1" height="12" alt="">
-<table cellpadding="0" cellspacing="0" border="0" summary="page content">
-<tbody><tr>
- <td width="250" valign="top" align="right">
- <a href="http://www.cl.cam.ac.uk/newlabphotos/"><img width="191" heigth="65" src="img/xeno.gif" border="0"></a>
-
-<table cellpadding="0" cellspacing="0" border="0" align="right">
-<tbody><tr>
- <td><img src="img/pixel.gif" class="block" width="20" height="1" alt=""></td>
-</tr>
-<tr>
- <td colspan="3"><img src="img/pixel.gif" class="block" width="1" height="10" alt=""></td>
-</tr>
-<tr>
- <td align="right">
- <table width="180" ><tbody><tr><td><p align="right">
-The XenoServer project aims to build a public infrastructure for wide-area distributed computing.
-</p>
- </td></tr></tbody></table></td>
-<td><img src="img/pixel.gif" class="block" width="10" height="1" alt=""></td>
-</tr>
-</tbody></table>
-</td>
-<td bgcolor="#666666" width="2"><img src="img/pixel.gif" class="block" width="2" height="50" alt=""></td>
-<td width="20"><img src="img/pixel.gif" class="block" width="20" height="1" alt=""></td>
-<td valign="top">
-
-<!-- main navigation -->
-<table cellpadding="0" cellspacing="0" border="0">
-
-<tbody><tr> <!-- list of menu items -->
- <td nowrap="nowrap">
- <b>Help</b>
-</td>
-</tr>
-
-<tr> <!-- blank white space -->
- <td><img src="img/pixel.gif" class="block" width="1" height="10" alt=""></td>
-</tr>
-
-<tr> <!-- grey line -->
- <td bgcolor="#cccccc"><img src="img/pixel.gif" class="block" width="1" height="2" alt=""></td>
-</tr>
-
-<tr> <!-- blank white space -->
- <td><img src="img/pixel.gif" class="block" width="1" height="10" alt=""></td>
-</tr>
-
-<tr> <!-- list of menu items -->
- <td nowrap="nowrap">Some help text will go here.
- </td>
-</tr>
-</tbody></table>
-</td>
-</tr>
-</tbody></table>
-<!-- end content -->
+++ /dev/null
-XenoServers
-COPYRIGHT&Computer Laboratory, University of Cambridge
-
-<!-- content -->
-<img src="img/pixel.gif" class="block" width="1" height="12" alt="">
-<table cellpadding="0" cellspacing="0" border="0" summary="page content">
-<tbody><tr>
- <td width="250" valign="top" align="right">
- <a href="http://www.cl.cam.ac.uk/xeno"><img width="191" heigth="65" src="img/xeno.gif" border="0"></a>
-
-<table cellpadding="0" cellspacing="0" border="0" align="right">
-<tbody>
-<tr>
- <td><img src="img/pixel.gif" class="block" width="20" height="1" alt=""></td>
-</tr>
-<tr>
- <td colspan="2"><img src="img/pixel.gif" class="block" width="1" height="10" alt=""></td>
-</tr>
-<tr>
- <td align="right">
- <table width="180" ><tbody><tr><td><p align="right">
- The XenoServer project aims to build a public infrastructure
- for wide-area distributed computing.
- </td></tr></tbody></table></td>
-<td><img src="img/pixel.gif" class="block" width="10" height="1" alt=""></td>
-</tr>
-</tbody></table>
-</td>
-<td bgcolor="#666666" width="2"><img src="img/pixel.gif" class="block" width="2" height="50" alt=""></td>
-<td width="20"><img src="img/pixel.gif" class="block" width="20" height="1" alt=""></td>
-<td valign="top">
-
-<!-- main navigation -->
-<table cellpadding="0" cellspacing="0" border="0">
-
-<tbody><tr> <!-- list of menu items -->
- <td nowrap="nowrap">
- <a href="about.jsp" class="homemenu">About the XenoServers Project</a><br>
-</td>
-</tr>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr>
- <td nowrap="nowrap">
- <a href="dom.jsp" class="homemenu">Domain Manager</a><br>
- <a href="vd.jsp" class="homemenu">Virtual Disk Manager</a><br>
- <a href="pd.jsp" class="homemenu">Physical Disk Manager</a><br>
- </td>
-</tr>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr>
- <td nowrap="nowrap">
- For additional information, click
- <a href="http://www.xenoserver.org">here</a>
- </td>
-</tr>
-
-
-##WHITESPACE##
-</tbody></table>
-</td>
-</tr>
-</tbody></table>
-<!-- end content -->
+++ /dev/null
-#!/usr/bin/perl5
-if($#ARGV<0) {
- &usage();
-} else {
-
- $headerfile = "xenohead.def" ;
- $footerfile = "xenofoot.def" ;
-
- $sectionbreak = "-" ;
- $supress_section = 0 ;
- $homepage = 0 ;
- $navigationwidth = 106;
- $navigationstring = "<td><a href=\"index.jsp\"><img src=\"img/home.gif\" width=\"53\" height=\"18\" border=\"0\" alt=\"XenoServers Home Page\" class=\"block\" /></a></td>";
- $whitespace = "<tr><td><img src=\"img/pixel.gif\" class=\"block\" width=\"1\" height=\"10\"></td></tr>";
- $greyline1 = "<tr><td bgcolor=\"#cccccc\"><img src=\"img/pixel.gif\" class=\"block\" width=\"1\" height=\"2\"></td></tr>";
- $greyline2 = "<tr><td bgcolor=\"#cccccc\" colspan=\"2\"><img src=\"img/pixel.gif\" class=\"block\" width=\"1\" height=\"2\"></td></tr>";
- $greyline3 = "<tr><td bgcolor=\"#cccccc\" colspan=\"3\"><img src=\"img/pixel.gif\" class=\"block\" width=\"1\" height=\"2\"></td></tr>";
- $greyline4 = "<tr><td bgcolor=\"#cccccc\" colspan=\"4\"><img src=\"img/pixel.gif\" class=\"block\" width=\"1\" height=\"2\"></td></tr>";
- $greyline14 = "<tr><td></td><td bgcolor=\"#cccccc\" colspan=\"4\"><img src=\"img/pixel.gif\" class=\"block\" width=\"1\" height=\"2\"></td></tr>";
-
-
- $login = getlogin || (getpwuid($<))[0] || "an unidentified user" ;
-
- $name =`finger $login | sed -n "s/Login.*:.*: //p"` ;
- if( $name eq "" ) { $name = $login ; }
-
- $date = `date +"on %-e-%b-%Y at %H:%M"` ;
-
- $year = `date +"%Y"` ;
-
- foreach $ag (@ARGV) {
-
- if( $ag =~ "^-s" ) {
- $supress_section = 1 ;
- }
- elsif( $ag =~ "^-home" ) {
- $homepage = 1 ;
- }
- else {
-
- $preagtmp = $ag . ".tmpl~$$";
- $agtmp = $ag . ".jsp~$$";
-
- open(PRETMPL,">$preagtmp") or die "Unable to write $preagtmp\n";
- print PRETMPL &doIncludes("$ag.tmpl");
- close(PRETMPL);
-
- open(TMPL,"<$preagtmp") or die "Unable to read $preagtmp\n";
-
- open(HTML,">$agtmp") or die "Unable to open $agtmp\n" ;
-
- $title=<TMPL> ;
-
- $sectionhead = "XenoServers" ;
- $copyright = "Computer Laboratory, University of Cambridge" ;
- $breadcrumbline = "" ;
- $commentcontact="<a href=\"mailto:pagemaster\@cl.cam.ac.uk\">pagemaster\@cl.cam.ac.uk</a>" ;
-
- $process_headings = 1 ;
- $tmp=<TMPL> ;
- while( $process_headings ) {
- $process_headings = 0 ;
-
- if( $tmp =~ /^SECTION&(.*)$/ ) {
- $sectionhead=$1 ;
- $process_headings = 1 ;
- }
-
- if( $tmp =~ /^COMMENTS&(.*)$/ ) {
- $commentcontact=$1 ;
- $process_headings = 1 ;
- }
-
- if( $tmp =~ /^COPYRIGHT&(.*)$/ ) {
- $copyright=$1 ;
- $process_headings = 1 ;
- }
-
- if( $tmp =~ /^HEADERFILE&(.*)$/ ) {
- $headerfile=$1 ;
- $process_headings = 1 ;
- }
-
- if( $tmp =~ /^FOOTERFILE&(.*)$/ ) {
- $footerfile=$1 ;
- $process_headings = 1 ;
- }
-
- if( $tmp =~ /BREADCRUMB&.*/ ) {
- @bread=split(/&/,$tmp) ;
- @bwords=split(/ /, @bread[1]) ;
- $bname=@bwords[0] ;
- for( $i=1 ; $i <= $#bwords ; $i++ ){
- $bname = $bname . " " . @bwords[$i] ;
- }
- $breadcrumbline = $breadcrumbline . " > <a href=\"" . @bread[2] . "\"class=\"bread\">" . $bname . "</a>" ;
- $process_headings = 1 ;
- }
-
- if( $process_headings ) {
- $tmp=<TMPL> ;
- }
- }
-
-#### generate the final breadcrumb which is the current file itself
- @path=split(/\//, $ag) ;
- $localfilename=@path[$#path] . ".jsp" ;
- @bwords=split(/ /, $title) ;
- $bname=@bwords[0] ;
- for( $i=1 ; $i <= $#bwords ; $i++ ){
- $bname = $bname . " " . @bwords[$i] ;
- }
- $breadcrumbline = $breadcrumbline . " > <a href=\"" . $localfilename . "\" class=\"bread\">" . $bname . "</a>" ;
-
-
-#### if suppressing the section header then do so now
- if( $supress_section ) {
- $sectionhead = "" ;
- $sectionbreak = "" ;
- }
-
-#### if homepage then do so now
- if( $homepage ) {
- $breadcrumbline = "" ;
- $navigationwidth = 53;
- $navigationstring = "";
- }
-
-
- open(HEADER,"<$headerfile") or die "Unable to open $headerfile\n" ;
- while(<HEADER>) {
- s/##TITLE##/$title/g ;
- s/##SECTION##/$sectionhead/g ;
- s/##SECTIONBREAK##/$sectionbreak/g ;
- s/##BREADCRUMBS##/$breadcrumbline/g ;
- s/##FILENAME##/$ag.jsp/g ;
- s/##DATE##/$date/g ;
- s/##OWNERNAME##/$name/g ;
- s/##OWNERUSERID##/$login/g ;
- s/##OWNEREMAIL##/$login\@cl.cam.ac.uk/g ;
- s/##COMMENTCONTACT##/$commentcontact/g ;
- s/##COPYRIGHT##/$copyright/g ;
- s/##YEAR##/$year/g ;
- s/##NAVIGATIONWIDTH##/$navigationwidth/g ;
- s/##NAVIGATIONSTRING##/$navigationstring/g ;
- print HTML $_ ;
- }
- close(HEADER) ;
-
- $_ = $tmp ;
- while(defined($_)) {
- s/##LISTSTART##/<ul>/g ;
- s/##ITEMHEAD##/<li>/g ;
- s/##ITEMBODY##/<br \/>/g ;
- s|##LISTEND##|</ul>|g ;
- s/##TITLE##/$title/g ;
- s/##SECTION##/$sectionhead/g ;
- s/##BREADCRUMBS##/$breadcrumbline/g ;
- s/##FILENAME##/$ag.jsp/g ;
- s/##DATE##/$date/g ;
- s/##OWNERNAME##/$name/g ;
- s/##OWNERUSERID##/$login/g ;
- s/##OWNEREMAIL##/$login\@cl.cam.ac.uk/g ;
- s/##COMMENTCONTACT##/$commentcontact/g ;
- s/##COPYRIGHT##/$copyright/g ;
- s/##YEAR##/$year/g ;
- s/##WHITESPACE##/$whitespace/g ;
- s/##GREYLINE1##/$greyline1/g ;
- s/##GREYLINE2##/$greyline2/g ;
- s/##GREYLINE3##/$greyline3/g ;
- s/##GREYLINE4##/$greyline4/g ;
- s/##GREYLINE14##/$greyline14/g ;
- print HTML $_ ;
- $_ = <TMPL>
- }
- open(FOOTER,"<$footerfile") or die "Unable to open $footerfile\n" ;
- while(<FOOTER>) {
- s/##TITLE##/$title/g ;
- s/##SECTION##/$sectionhead/g ;
- s/##BREADCRUMBS##/$breadcrumbline/g ;
- s/##FILENAME##/$ag.jsp/g ;
- s/##DATE##/$date/g ;
- s/##OWNERNAME##/$name/g ;
- s/##OWNERUSERID##/$login/g ;
- s/##OWNEREMAIL##/$login\@cl.cam.ac.uk/g ;
- s/##COMMENTCONTACT##/$commentcontact/g ;
- s/##COPYRIGHT##/$copyright/g ;
- s/##YEAR##/$year/g ;
- print HTML $_ ;
- }
- close(FOOTER) ;
- close(HTML);
- close(TMPL);
-
- if( system "mv $agtmp $ag.jsp" ) {
- die "Unable to rename $agtmp to $ag.jsp\n" ; ;
- }
- if( system "rm $preagtmp" ) {
- die "Unable to remove $preagtmp\n" ; ;
- }
- }
- }
-}
-
-sub usage
-{
- print "Usage: install.pl [-s] <name>\n";
- print " Installs web page <name>.jsp based on <name>.tmpl\n";
- print " -s supresses the generation of any section title";
- print " which says `Computer Laboratory' in the default" ;
- print " case or is specified by SECTION& in the .tmpl file" ;
- exit;
-}
-
-sub doIncludes
-{
- my $infile=$_[0];
- my $out="";
- my $tmp;
- my $incfile;
- my @lines;
- my $line;
-
- open(FIN,"<$infile") or die "doIncludes unable to read from $infile\n";
- @lines=<FIN>;
- close(FIN);
- foreach $line (@lines) {
- if( $line =~ /^INCLUDE&.*/ ) {
- ($tmp,$incfile) = split(/&/,$line);
- $out=$out.&doIncludes($incfile);
- } else {
- $out=$out.$line;
- }
- }
- return $out;
-}
+++ /dev/null
-src0 = xenostyle.css
-src1 = index.jsp about.jsp help.jsp vd.jsp \
- vd-pv.jsp vd-pa.jsp vd-vdv.jsp vd-vdc.jsp vd-vdd.jsp vd-vdr.jsp \
- vd-fv.jsp vd-vbdv.jsp vd-vbdc.jsp \
- vd-par.jsp vd-vdcr.jsp vd-vddr.jsp vd-vdrr.jsp vd-vbdcr.jsp \
- dom.jsp dom-lis.jsp dom-new.jsp dom-newr.jsp dom-sta.jsp dom-star.jsp \
- dom-stp.jsp dom-stpr.jsp dom-del.jsp dom-delr.jsp \
- pd.jsp pd-g.jsp pd-gr.jsp pd-l.jsp pd-r.jsp pd-rr.jsp
-target = ..
-target0 = $(target)/xenostyle.css
-target1 = $(target)/index.jsp $(target)/vd.jsp \
- $(target)/vd-pv.jsp $(target)/vd-pa.jsp $(target)/vd-vdv.jsp \
- $(target)/vd-vdc.jsp $(target)/vd-vdd.jsp $(target)/vd-vdr.jsp \
- $(target)/vd-fv.jsp $(target)/vd-vbdv.jsp $(target)/vd-vbdc.jsp \
- $(target)/about.jsp $(target)/help.jsp \
- $(target)/vd-par.jsp $(target)/vd-vdcr.jsp $(target)/vd-vddr.jsp \
- $(target)/vd-vdrr.jsp $(target)/vd-vbdcr.jsp \
- $(target)/dom.jsp $(target)/dom-lis.jsp $(target)/dom-new.jsp \
- $(target)/dom-newr.jsp $(target)/dom-sta.jsp $(target)/dom-star.jsp \
- $(target)/dom-stp.jsp $(target)/dom-stpr.jsp \
- $(target)/dom-del.jsp $(target)/dom-delr.jsp \
- $(target)/pd.jsp $(target)/pd-g.jsp $(target)/pd-gr.jsp \
- $(target)/pd-l.jsp $(target)/pd-r.jsp $(target)/pd-rr.jsp
-
-.SUFFIXES: .tmpl .jsp
-
-all: $(target1) $(target0)
-
-$(target)/index.jsp: index.tmpl
- ./install.pl -s -home index
- mv index.jsp $(target)
-
-$(target)/%.jsp: %.tmpl xenofoot.def xenohead.def
- ./install.pl $*
- mv $*.jsp $(target)
-
-$(target0): $(src0)
- cp -f $(src0) $(target)
-
-clean:
- rm -f $(target1) $(target0)
+++ /dev/null
-Grant Access
-SECTION&XenoServers
-BREADCRUMB&Physical Disk Manager&pd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&pdmenu.tmpl
-<td valign="top">
-
-<form method="post" action="pd-gr.jsp">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-
-<tr><td>
-
-<table cellpadding="2" cellspacing="0" border="0">
-<tbody>
- <tr class="vdh"><td></td><td>maj:min</td><td>blocks</td><td>start sect</td><td>num sects</td><td>name</td></tr>
- <%
- int count = root.pm().getPartitionCount();
- for (int loop = 0; loop < count; loop++)
- {
- Partition p = root.pm().getPartition(loop);
- if (p.isXeno() == true)
- {
- %>
- <tr class="vds"><td></td>
- <%
- }
- else
- {
- %>
- <tr class="vdt">
- <td><input type="checkbox" name="p" value="<%= p.getName() %>"></td>
- <%
- }
- %>
- <td><%= p.getMajor() %>:<%= p.getMinor() %></td>
- <td align="right"><%= p.getBlocks() %></td>
- <td align="right"><%= p.getStartSect() %> </td>
- <td align="right"><%= p.getNumSects() %> </td>
- <td><%= p.getName() %> </td>
- </tr>
- <%
- }
- %>
-</tbody>
-</table>
-
-</td></tr>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr><td>
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-
-<tr>
- <td width="100"></td>
- <td width="7"></td>
- <td></td>
-</tr>
-
-<tr>
- <td align="right">domain</td>
- <td></td>
- <td> <input type="text" size="3" name="domain"> </td>
-</tr>
-<tr>
- <td align="right"></td>
- <td></td>
- <td> <input type="radio" name="mode" value="ro" checked>RO
- <input type="radio" name="mode" value="rw">RW</td>
-</tr>
-</tbody>
-</table>
-</td></tr>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr>
- <td><input type="submit" name="action" value="grant access"></td>
-</tr>
-
-</tbody>
-</table>
-</form>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Grant Access Results
-SECTION&XenoServers
-BREADCRUMB&Physical Disk Manager&pd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&pdmenu.tmpl
-<td valign="top">
-
-<b>Grant Access Results</b>
-<br>
-
-<%
- HttpServletRequestWrapper hsrw = new HttpServletRequestWrapper(request);
- Defaults d = sc.getDefaults();
-
- String partitions[] = hsrw.getParameterValues("p");
- String size = null;
-
- if (partitions == null || partitions.length == 0)
- {
-%>
-Error: No partitions chosen.<br>
-<%
- }
- else if (hsrw.getParameter("domain") == null ||
- hsrw.getParameter("domain").trim().equals(""))
- {
-%>
-Error: No domain specified.<br>
-<%
- }
- else
- {
- int domain = -1;
-
- try
- {
- domain = Integer.decode(hsrw.getParameter("domain")).intValue();
- Mode mode;
- if (hsrw.getParameter("mode").equals("rw")) {
- mode = Mode.READ_WRITE;
- } else {
- mode = Mode.READ_ONLY;
- }
-
- for (int i = 0; i < partitions.length; i++)
- {
-%>
-output[<%= i %>] =<br>
-<%= new CommandPhysicalGrant(d, domain, partitions[i], mode, false).executeWeb() %> <br>
-<%
- }
- } catch (NumberFormatException e) {
-%>
-Error: invalid domain specification.<br>
-<%
- }
- }
-%>
-
-
-<%
- root.doFlushState();
-%>
-
-
-</td>
-</tbody>
-</table>
-
-
-
-<!-- end content -->
+++ /dev/null
-Physical Access List
-SECTION&XenoServers
-BREADCRUMB&Physical Disk Manager&pd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&pdmenu.tmpl
-<td valign="top">
-
-<%
- CommandDomainList list = new CommandDomainList(sc.getDefaults());
- String output = list.executeWeb();
- if (output != null)
- {
-%>
-<%= output %>
-<%
- } else {
- Domain domains[] = list.domains();
-%>
-
-<table cellpadding="2" cellspacing="0" border="0">
-<tbody>
- <tr class="vdh"><td>domain<br>id</td><td>mode</td><td>maj:min</td><td>blocks</td><td>start sect</td><td>num sects</td><td>name</td></tr>
- <%
- /* assert: domains != null, otherwise, where is the servlet engine? */
- for (int loop = 0; loop < domains.length; loop++)
- {
- if ( domains[loop].id == 0 )
- continue;
- CommandPhysicalList plist = new CommandPhysicalList(sc.getDefaults(),domains[loop].id);
- output = plist.executeWeb();
- if (output != null)
- {
-%>
-<%= output %>
-<%
- } else {
- Iterator i = plist.extents().entrySet().iterator();
- while (i.hasNext()) {
- Entry entry = (Entry) i.next();
- Extent e = (Extent) entry.getKey();
- String mode = entry.getValue().toString();
- Partition p = root.pm().getPartition(e);
- if (p != null) {
- %>
- <tr>
- <td><%= domains[loop].id %></td>
- <td><%= mode %></td>
- <td><%= p.getMajor() %>:<%= p.getMinor() %></td>
- <td align="right"><%= p.getBlocks() %></td>
- <td align="right"><%= p.getStartSect() %> </td>
- <td align="right"><%= p.getNumSects() %> </td>
- <td><%= p.getName() %> </td>
- </tr>
- <%
- } else {
- %>
- <tr>
- <td><%= domains[loop].id %></td>
- <td><%= mode %></td>
- <td><%= e.getMajor() %>:<%= e.getMinor()|e.getPartitionNo() %></td>
- <td align="right"></td>
- <td align="right"><%= e.getOffset() %> </td>
- <td align="right"><%= e.getSize() %> </td>
- <td></td>
- </tr>
- <%
- }
- }
- }
- }
- %>
-</tbody>
-</table>
-<%
- }
-%>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Revoke Access
-SECTION&XenoServers
-BREADCRUMB&Physical Disk Manager&pd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&pdmenu.tmpl
-<td valign="top">
-
-<%
- CommandDomainList list = new CommandDomainList(sc.getDefaults());
- String output = list.executeWeb();
- if (output != null)
- {
-%>
-<%= output %>
-<%
- } else {
- Domain domains[] = list.domains();
-%>
-
-<form method="post" action="pd-rr.jsp">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-<tr><td>
-<table cellpadding="2" cellspacing="0" border="0">
-<tbody>
- <tr class="vdh"><td></td><td>domain<br>id</td><td>mode</td><td>maj:min</td><td>blocks</td><td>start sect</td><td>num sects</td><td>name</td></tr>
- <%
- /* assert: domains != null, otherwise, where is the servlet engine? */
- for (int loop = 0; loop < domains.length; loop++)
- {
- if ( domains[loop].id == 0 )
- continue;
- CommandPhysicalList plist = new CommandPhysicalList(sc.getDefaults(),domains[loop].id);
- output = plist.executeWeb();
- if (output != null)
- {
-%>
-<%= output %>
-<%
- } else {
- Iterator i = plist.extents().entrySet().iterator();
- while (i.hasNext()) {
- Entry entry = (Entry) i.next();
- Extent e = (Extent) entry.getKey();
- String mode = entry.getValue().toString();
- Partition p = root.pm().getPartition(e);
- if (p != null) {
- %>
- <tr>
- <td><input type="checkbox" name="dompart" value="<%= domains[loop].id + " " + p.getName() %>"></td>
- <td><%= domains[loop].id %></td>
- <td><%= mode %></td>
- <td><%= p.getMajor() %>:<%= p.getMinor() %></td>
- <td align="right"><%= p.getBlocks() %></td>
- <td align="right"><%= p.getStartSect() %> </td>
- <td align="right"><%= p.getNumSects() %> </td>
- <td><%= p.getName() %> </td>
- </tr>
- <%
- } else {
- %>
- <tr>
- <td><%= domains[loop].id %></td>
- <td><%= mode %></td>
- <td><%= e.getMajor() %>:<%= e.getMinor()|e.getPartitionNo() %></td>
- <td align="right"></td>
- <td align="right"><%= e.getOffset() %> </td>
- <td align="right"><%= e.getSize() %> </td>
- <td></td>
- </tr>
- <%
- }
- }
- }
- }
- %>
-</tbody>
-</table>
-</td></tr>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr>
- <td><input type="submit" name="action" value="revoke access"></td>
-</tr>
-</table>
-</form>
-<%
- }
-%>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Revoke Access
-SECTION&XenoServers
-BREADCRUMB&Physical Disk Manager&pd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&pdmenu.tmpl
-<td valign="top">
-
-<b>Revoke Access Results</b>
-<br>
-<%
- HttpServletRequestWrapper hsrw = new HttpServletRequestWrapper(request);
-
- String partitions[] = hsrw.getParameterValues("dompart");
- if (partitions == null || partitions.length == 0)
- {
-%>
-Error: No partitions chosen.<br>
-<%
- }
- else
- {
- for (int i = 0; i < partitions.length; i++)
- {
- int domain = Integer.parseInt(partitions[i].substring(0,partitions[i].indexOf(" ")));
- String partition = partitions[i].substring(partitions[i].indexOf(" ")+1);
-%>
-output[<%= i %>] =<br>
-<%= new CommandPhysicalRevoke(sc.getDefaults(),domain,partition).executeWeb() %> <br>
-<%
- }
- }
-%>
-
-<%
- root.doFlushState();
-%>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Physical Disk Manager
-SECTION&XenoServers
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&pdmenu.tmpl
-<td valign="top">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
- <tr><td nowrap="nowrap">Physical Disk Manager</td></tr>
-
-</tbody>
-</table>
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-<td width="10" valign="top" align="right"></td>
-
-<td valign="top">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-<tr>
- <td class="menuheader" width="100">Physical Disk Access</td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="pd-g.jsp">Grant</a></td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="pd-r.jsp">Revoke</a></td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="pd-l.jsp">List</a></td>
-</tr>
-</tbody>
-</table>
-</td>
-
-<td width="5" valign="top" align="right"></td>
-
-<td bgcolor="#666666" width="2"><img src="img/pixel.gif" class="block" width="2" height="50"></td>
-
-<td width="15" valign="top" align="right"></td>
+++ /dev/null
-View Free Space
-SECTION&XenoServers
-BREADCRUMB&Virtual Disk Manager&vd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&vdmenu.tmpl
-<td valign="top">
-
-<%
- VirtualDisk free = root.vdm().getFreeDisk();
-%>
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-
-<tr><td>
-Total available free space: <%= Library.formatSize(free.getSize() * Settings.SECTOR_SIZE,8,true) %>
-</td></tr>
-
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr><td>
-<table cellpadding="2" cellspacing="0" border="0">
-<tbody>
- <tr class="vdh"><td>disk</td><td>offset</td><td>size </td></tr>
-
- <%
- Iterator i = free.extents();
- while (i.hasNext())
- {
- Extent e = (Extent) i.next();
- %>
- <tr class="vdt">
- <td ><%= e.getDisk() %></td>
- <td align="right"><%= e.getOffset() %> </td>
- <td align="right"><%= e.getSize() %> </td>
- </tr>
- <%
- }
- %>
-</tbody>
-</table>
-</td></tr>
-
-</tbody>
-</table>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Add Partition
-SECTION&XenoServers
-BREADCRUMB&Virtual Disk Manager&vd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&vdmenu.tmpl
-<td valign="top">
-
-<form method="post" action="vd-par.jsp">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-
-<tr><td>
-
-<table cellpadding="2" cellspacing="0" border="0">
-<tbody>
- <tr class="vdh"><td></td><td>maj:min</td><td>blocks</td><td>start sect</td><td>num sects</td><td>name</td></tr>
- <%
- int count = root.pm().getPartitionCount();
- for (int loop = 0; loop < count; loop++)
- {
- Partition p = root.pm().getPartition(loop);
- if (p.isXeno() == true)
- {
- %>
- <tr class="vds"><td></td>
- <%
- }
- else
- {
- %>
- <tr class="vdt">
- <td><input type="checkbox" name="p" value="<%= p.getName() %>"></td>
- <%
- }
- %>
- <td><%= p.getMajor() %>:<%= p.getMinor() %></td>
- <td align="right"><%= p.getBlocks() %></td>
- <td align="right"><%= p.getStartSect() %> </td>
- <td align="right"><%= p.getNumSects() %> </td>
- <td><%= p.getName() %> </td>
- </tr>
- <%
- }
- %>
-</tbody>
-</table>
-
-</td></tr>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-
-<tr><td>
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-
-<tr>
- <td width="50"></td>
- <td width="7"></td>
- <td></td>
-</tr>
-
-<tr>
- <td align="right">chunksize</td>
- <td></td>
- <td> <input type="text" size="5" name="chunk" value="256">
- <input type="radio" name="chunkunits" value="m" checked>MB
- <input type="radio" name="chunkunits" value="g">GB
- </td>
-</tr>
-</tbody>
-</table>
-</td></tr>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr>
- <td><input type="submit" name="action" value="add partition"></td>
-</tr>
-
-</tbody>
-</table>
-</form>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Add Partition Results
-SECTION&XenoServers
-BREADCRUMB&Virtual Disk Manager&vd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&vdmenu.tmpl
-<td valign="top">
-
-<b>Add Partition Results</b>
-<br>
-
-<%
- HttpServletRequestWrapper hsrw = new HttpServletRequestWrapper(request);
-
- String partitions[] = hsrw.getParameterValues("p");
- String size = null;
-
- if (partitions == null || partitions.length == 0)
- {
-%>
-Error: No partitions chosen.<br>
-<%
- }
- else if (hsrw.getParameter("chunk") == null ||
- hsrw.getParameter("chunk").trim().equals(""))
- {
-%>
-Error: chunk size not specified.<br>
-<%
- }
- else
- {
- size = hsrw.getParameter("chunk").trim() +
- hsrw.getParameter("chunkunits").trim();
- for (int i = 0; i < partitions.length; i++)
- {
-%>
-output[<%= i %>] =<br>
-<%= new CommandPartitionAdd(partitions[i], Library.parseSize(size), false).executeWeb() %> <br>
-<%
- }
- }
-%>
-
-
-<%
- root.doFlushState();
-%>
-
-
-</td>
-</tbody>
-</table>
-
-
-
-<!-- end content -->
+++ /dev/null
-View Partitions
-SECTION&XenoServers
-BREADCRUMB&Virtual Disk Manager&vd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&vdmenu.tmpl
-<td valign="top">
-note: highlighted entries are currently being used as xeno partitions.
-<br><br>
-
-<table cellpadding="2" cellspacing="0" border="0">
-<tbody>
- <tr class="vdh"><td>maj:min</td><td>blocks</td><td>start sect</td><td>num sects</td><td>name</td></tr>
- <%
- int count = root.pm().getPartitionCount();
- for (int loop = 0; loop < count; loop++)
- {
- Partition p = root.pm().getPartition(loop);
- if (p.isXeno() == true)
- {
- %>
- <tr class="vds">
- <%
- }
- else
- {
- %>
- <tr class="vdt">
- <%
- }
- %>
- <td><%= p.getMajor() %>:<%= p.getMinor() %></td>
- <td align="right"><%= p.getBlocks() %></td>
- <td align="right"><%= p.getStartSect() %> </td>
- <td align="right"><%= p.getNumSects() %> </td>
- <td><%= p.getName() %> </td>
- <%
- }
- %>
-</tbody>
-</table>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Create Virtual Block Device
-SECTION&XenoServers
-BREADCRUMB&Virtual Disk Manager&vd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&vdmenu.tmpl
-<td valign="top">
-
-<form method="post" action="vd-vbdcr.jsp">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-<tr><td>
-<table cellpadding="2" cellspacing="0" border="0">
-<tbody>
- <tr class="vdh"><td></td><td>vd key</td><td width="5"></td><td>name</td><td width="5"></td><td>expiry</td><td width="5"></td><td>size</td></tr>
-
- <%
- Iterator i = root.vdm().getVirtualDisks();
- while (i.hasNext())
- {
- VirtualDisk vd = (VirtualDisk) i.next();
- %>
- <tr class="vdt">
- <td>
- <input type="radio" name="vd" value="<%= vd.getKey() %>">
- </td>
- <td><%= vd.getKey() %></td>
- <td></td>
- <td><%= vd.getName() %></td>
- <td></td>
- <td><%= vd.getExpiry() %></td>
- <td></td>
- <td><%= Library.formatSize(vd.getSize()*Settings.SECTOR_SIZE,8,false) %></td>
- </tr>
- <%
- }
- %>
-
-</tbody>
-</table>
-</td></tr>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr><td>
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-
-<tr>
- <td width="100"></td>
- <td width="7"></td>
- <td></td>
-</tr>
-
-<tr>
- <td align="right">domain</td>
- <td></td>
- <td> <input type="text" size="3" name="domain"> </td>
-</tr>
-<tr>
- <td align="right">vbd number</td>
- <td></td>
- <td> <input type="text" size="3" name="vbd"> </td>
-</tr>
-<tr>
- <td align="right"></td>
- <td></td>
- <td> <input type="radio" name="mode" value="ro" checked>RO
- <input type="radio" name="mode" value="rw">RW</td>
-</tr>
-</tbody>
-</table>
-</td></tr>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr>
- <td><input type="submit" name="action" value="create virtual block device"></td>
-</tr>
-</table>
-</form>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Create Virtual Block Device
-SECTION&XenoServers
-BREADCRUMB&Virtual Disk Manager&vd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&vdmenu.tmpl
-<td valign="top">
-
-<b>Create Virtual Block Device Results</b>
-<br>
-
-<%
- HttpServletRequestWrapper hsrw = new HttpServletRequestWrapper(request);
-
- if (hsrw.getParameter("vd") == null ||
- hsrw.getParameter("vd").trim().equals(""))
- {
-%>
-Error: No virtual disk chosen.<br>
-<%
- }
- else if (hsrw.getParameter("domain") == null ||
- hsrw.getParameter("domain").trim().equals(""))
- {
-%>
-Error: No domain specified.<br>
-<%
- }
- else if (hsrw.getParameter("vbd") == null ||
- hsrw.getParameter("vbd").trim().equals(""))
- {
-%>
-Error: No virtual block device number specified.<br>
-<%
- }
- else
- {
- int domain = -1;
- int vbd = -1;
-
- try
- {
- domain = Integer.decode(hsrw.getParameter("domain")).intValue();
- vbd = Integer.decode(hsrw.getParameter("vbd")).intValue();
- Mode mode;
- if (hsrw.getParameter("mode").equals("rw")) {
- mode = Mode.READ_WRITE;
- } else {
- mode = Mode.READ_ONLY;
- }
-
-%>
-output =<br>
-<%= new CommandVbdCreate(hsrw.getParameter("vd"),
- domain, vbd,
- mode).executeWeb() %>
-<%
- }
- catch (NumberFormatException e)
- {
- if (domain == -1)
- {
-%>
-Error: invalid domain specification.<br>
-<%
- }
- else
- {
-%>
-Error: invalid virtual block device number specification.<br>
-<%
- }
- }
- }
-%>
-
-<%
- root.doFlushState();
-%>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-View Virtual Block Devices
-SECTION&XenoServers
-BREADCRUMB&Virtual Disk Manager&vd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&vdmenu.tmpl
-<td valign="top">
-<%
- CommandVbdList list = new CommandVbdList();
- String output = list.executeWeb();
- VirtualBlockDevice[] vbds = list.vbds();
- if (output != null)
- {
-%>
-<%= output %>
-<%
- } else {
-%>
-<table cellpadding="2" cellspacing="0" border="0">
-<tbody>
- <tr class="vdh"><td>dom</td><td>vbd</td><td>mode</td><td>vd key</td><td>vd name</td></tr>
-
-
- <%
- for (int i=0;i<vbds.length;i++)
- {
- VirtualBlockDevice vbd = vbds[i];
- VirtualDisk vd = vbd.getVirtualDisk();
- %>
- <tr class="vdt">
- <td><%= vbd.getDomain() %></td>
- <td><%= vbd.getVbdNum() %></td>
- <td><%= vbd.getMode().toString() %></td>
- <td><%= vd.getKey() %></td>
- <td><%= vd.getName() %></td>
- </tr>
- <%
- }
- %>
-</tbody>
-</table>
-<%
- }
-%>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Create New Virtual Disk
-SECTION&XenoServers
-BREADCRUMB&Virtual Disk Manager&vd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&vdmenu.tmpl
-<td valign="top">
-
-<form method="post" action="vd-vdcr.jsp">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-
-<tr>
- <td width="50"></td>
- <td width="7"></td>
- <td></td>
-</tr>
-
-<tr>
- <td align="right">name</td>
- <td></td>
- <td> <input type="text" size="40" name="name" value="name of disk"> </td>
-</tr>
-
-<tr>
- <td align="right">size</td>
- <td></td>
- <td> <input type="text" size="10" name="size">
- <input type="radio" name="sizeunits" value="mb" checked>MB
- <input type="radio" name="sizeunits" value="gb">GB
- </td>
-</tr>
-
-<tr>
- <td align="right">expiry</td>
- <td></td>
- <td> <input type="text" size="3" name="expiry">
- <input type="radio" name="expiryunits" value="d" checked>days
- <input type="radio" name="expiryunits" value="w">weeks
- <input type="radio" name="expiryunits" value="m">months
- <input type="radio" name="expiryunits" value="y">years
- </td>
-</tr>
-
-##WHITESPACE## ##GREYLINE3## ##WHITESPACE##
-
-<tr>
- <td></td>
- <td></td>
- <td><input type="submit" name="action" value="create virtual disk"></td>
-</tr>
-
-</tbody>
-</table>
-</form>
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Create New Virtual Disk
-SECTION&XenoServers
-BREADCRUMB&Virtual Disk Manager&vd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&vdmenu.tmpl
-<td valign="top">
-
-
-<b>Create Virtual Disk Results</b>
-<br>
-
-<%
- HttpServletRequestWrapper hsrw = new HttpServletRequestWrapper(request);
- String size = null;
- String expiry_string = null;
- long expiry = 0;
-
- if (hsrw.getParameter("size") == null ||
- hsrw.getParameter("size").trim().equals(""))
- {
-%>
-Error: size not specified.<br>
-<%
- }
- else if (hsrw.getParameter("expiry") == null ||
- hsrw.getParameter("expiry").trim().equals(""))
- {
-%>
-Error: expiry time not specified.<br>
-<%
- }
- else
- {
- size = hsrw.getParameter("size").trim() +
- hsrw.getParameter("sizeunits").trim();
-
- try
- {
- expiry = Long.decode(hsrw.getParameter("expiry")).longValue();
-
- /* not perfect, but good enough for now... */
- if ( hsrw.getParameter("expiryunits").equals("d"))
- {
- expiry *= 24 * 60 * 60 * 1000;
- }
- else if ( hsrw.getParameter("expiryunits").equals("w"))
- {
- expiry *= 24 * 60 * 60 * 1000 * 7;
- }
- else if ( hsrw.getParameter("expiryunits").equals("m"))
- {
- expiry *= 24 * 60 * 60 * 1000 * 30;
- }
- else if ( hsrw.getParameter("expiryunits").equals("y"))
- {
- expiry *= 24 * 60 * 60 * 1000 * 365;
- }
-
- expiry += System.currentTimeMillis();
-%>
-output =<br>
-<%= new CommandVdCreate( hsrw.getParameter("name"), Library.parseSize(size), new Date(expiry)).executeWeb() %>
-<br>
-<%
- }
- catch (NumberFormatException e)
- {
-%>
-Error: invalid expiry time specification.<br>
-<%
- }
- }
-%>
-
-<%
- root.doFlushState();
-%>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Delete Virtual Disk
-SECTION&XenoServers
-BREADCRUMB&Virtual Disk Manager&vd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&vdmenu.tmpl
-<td valign="top">
-
-<form method="post" action="vd-vddr.jsp">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-<tr><td>
-<table cellpadding="2" cellspacing="0" border="0">
-<tbody>
- <tr class="vdh"><td></td><td>key</td><td width="5"></td><td>name</td><td width="5"></td><td>expiry</td><td width="5"></td><td>size</td></tr>
-
- <%
- Iterator i = root.vdm().getVirtualDisks();
- while (i.hasNext())
- {
- VirtualDisk vd = (VirtualDisk) i.next();
- %>
- <tr class="vdt">
- <td><input type="checkbox" name="vd" value="<%= vd.getKey() %>"></td>
- <td><%= vd.getKey() %></td>
- <td></td>
- <td><%= vd.getName() %></td>
- <td></td>
- <td><%= vd.getExpiry() %></td>
- <td></td>
- <td><%= Library.formatSize(vd.getSize()*Settings.SECTOR_SIZE,8,false) %></td>
- </tr>
- <%
- }
- %>
-
-
-</tbody>
-</table>
-</td></tr>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr>
- <td><input type="submit" name="action" value="delete virtual disk"></td>
-</tr>
-</table>
-</form>
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Delete Virtual Disk
-SECTION&XenoServers
-BREADCRUMB&Virtual Disk Manager&vd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&vdmenu.tmpl
-<td valign="top">
-
-<b>Delete Virtual Disk Results</b>
-<br>
-<%
- HttpServletRequestWrapper hsrw = new HttpServletRequestWrapper(request);
-%>
-
-vd= <%= hsrw.getParameter("vd") %>
-
-vd= <%= new CommandVdDelete(hsrw.getParameter("vd"),false).executeWeb() %>
-
-<%
- root.doFlushState();
-%>
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Refresh Virtual Disk
-SECTION&XenoServers
-BREADCRUMB&Virtual Disk Manager&vd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&vdmenu.tmpl
-<td valign="top">
-
-<form method="post" action="vd-vdrr.jsp">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-<tr><td>
-<table cellpadding="2" cellspacing="0" border="0">
-<tbody>
- <tr class="vdh"><td></td><td>key</td><td width="5"></td><td>name</td><td width="5"></td><td>expiry</td><td width="5"></td><td>size</td></tr>
-
- <%
- Iterator i = root.vdm().getVirtualDisks();
- while (i.hasNext())
- {
- VirtualDisk vd = (VirtualDisk) i.next();
- %>
- <tr class="vdt">
- <td><input type="checkbox" name="vd" value="<%= vd.getKey() %>"></td>
- <td><%= vd.getKey() %></td>
- <td></td>
- <td><%= vd.getName() %></td>
- <td></td>
- <td><%= vd.getExpiry() %></td>
- <td></td>
- <td><%= Library.formatSize(vd.getSize()*Settings.SECTOR_SIZE,8,false) %></td>
- </tr>
- <%
- }
- %>
-
-</tbody>
-</table>
-</td></tr>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr><td>
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-
-<tr>
- <td width="50"></td>
- <td width="7"></td>
- <td></td>
-</tr>
-
-<tr>
- <td align="right">new<br>expiry</td>
- <td></td>
- <td> <input type="text" size="3" name="expiry">
- <input type="radio" name="expiryunits" value="d" checked>days
- <input type="radio" name="expiryunits" value="w">weeks
- <input type="radio" name="expiryunits" value="m">months
- <input type="radio" name="expiryunits" value="y">years
- </td>
-</tr>
-</tbody>
-</table>
-</td></tr>
-
-##WHITESPACE## ##GREYLINE1## ##WHITESPACE##
-
-<tr>
- <td><input type="submit" name="action" value="refresh expiry time"></td>
-</tr>
-</table>
-</form>
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Refresh Virtual Disk
-SECTION&XenoServers
-BREADCRUMB&Virtual Disk Manager&vd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&vdmenu.tmpl
-<td valign="top">
-
-<%
- HttpServletRequestWrapper hsrw = new HttpServletRequestWrapper(request);
-
- String vds[] = hsrw.getParameterValues("vd");
- long expiry;
-
- if (vds == null || vds.length == 0)
- {
-%>
-Error: No virtual disk chosen.<br>
-<%
- }
- else if (hsrw.getParameter("expiry") == null ||
- hsrw.getParameter("expiry").trim().equals(""))
- {
-%>
-Error: expiry time not specified.<br>
-<%
- }
- else
- {
- expiry = Long.decode(hsrw.getParameter("expiry")).longValue();
-
- /* not perfect, but good enough for now... */
- if ( hsrw.getParameter("expiryunits").equals("d"))
- {
- expiry *= 24 * 60 * 60 * 1000;
- }
- else if ( hsrw.getParameter("expiryunits").equals("w"))
- {
- expiry *= 24 * 60 * 60 * 1000 * 7;
- }
- else if ( hsrw.getParameter("expiryunits").equals("m"))
- {
- expiry *= 24 * 60 * 60 * 1000 * 30;
- }
- else if ( hsrw.getParameter("expiryunits").equals("y"))
- {
- expiry *= 24 * 60 * 60 * 1000 * 365;
- }
-
- expiry += System.currentTimeMillis();
-
- for (int i = 0; i < vds.length; i++)
- {
-%>
-vd = <%= new CommandVdRefresh(vds[i], new Date(expiry)).executeWeb() %> <br>
-<%
- }
- }
-%>
-
-<%
- root.doFlushState();
-%>
-
-
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-View Virtual Disks
-SECTION&XenoServers
-BREADCRUMB&Virtual Disk Manager&vd.jsp
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&vdmenu.tmpl
-<td valign="top">
-
-<table cellpadding="2" cellspacing="0" border="0">
-<tbody>
- <tr class="vdh"><td>key</td><td width="5"></td><td>name</td><td width="5"></td><td>expiry</td><td width="5"></td><td>size</td></tr>
-
- <%
- Iterator i = root.vdm().getVirtualDisks();
- while (i.hasNext())
- {
- VirtualDisk vd = (VirtualDisk) i.next();
- %>
- <tr class="vdt">
- <td><%= vd.getKey() %></td>
- <td></td>
- <td><%= vd.getName() %></td>
- <td></td>
- <td><%= vd.getExpiry() %></td>
- <td></td>
- <td><%= Library.formatSize(vd.getSize()*Settings.SECTOR_SIZE,8,false) %></td>
- </tr>
- <%
- }
- %>
-
-</tbody>
-</table>
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-Virtual Disk Manager
-SECTION&XenoServers
-
-<!-- content -->
-<img src="pixel.gif" class="block" width="1" height="12">
-
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-INCLUDE&vdmenu.tmpl
-<td valign="top">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
- <tr><td nowrap="nowrap">Virtual Disk Manager</td></tr>
-
-</tbody>
-</table>
-</td>
-</tbody>
-</table>
-
-
-
-
-<!-- end content -->
+++ /dev/null
-<td width="10" valign="top" align="right"></td>
-
-<td valign="top">
-<table cellpadding="0" cellspacing="0" border="0">
-<tbody>
-<tr>
- <td class="menuheader" width="100">Partitions</td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="vd-pv.jsp">View</a></td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="vd-pa.jsp">Add</a></td>
-</tr>
-##WHITESPACE##
-<tr>
- <td class="menuheader" width="100">Virtual Disk</td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="vd-vdv.jsp">View</a></td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="vd-vdc.jsp">Create</a></td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="vd-vdd.jsp">Delete</a></td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="vd-vdr.jsp">Refresh</a></td>
-</tr>
-##WHITESPACE##
-<tr>
- <td class="menuheader" width="100">Free Space</td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="vd-fv.jsp">View</a></td>
-</tr>
-##WHITESPACE##
-<tr>
- <td class="menuheader" width="100">Virtual Block Device</td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="vd-vbdv.jsp">View</a></td>
-</tr>
-<tr>
- <td class="sidemenu" width="100"><a href="vd-vbdc.jsp">Create</a></td>
-</tr>
-
-</tbody>
-</table>
-</td>
-
-<td width="5" valign="top" align="right"></td>
-
-<td bgcolor="#666666" width="2"><img src="img/pixel.gif" class="block" width="2" height="50"></td>
-
-<td width="15" valign="top" align="right"></td>
+++ /dev/null
-<!-- START OF STANDARD FOOTER-->
-</td>
-</tr></table>
-<!-- end body text -->
-
-<!-- footer -->
-<br />
-<table cellpadding="0" cellspacing="0" border="0" width="98%" summary="footer">
-<tr><td bgcolor="#0099cc" colspan="2"><img
-src="http://www.cl.cam.ac.uk/UoCCL/images/pixel.gif" class="block" width="1" height="4" border="0" alt="" /></td>
-</tr>
-<tr><td bgcolor="#cccccc" colspan="2"><img
-src="http://www.cl.cam.ac.uk/UoCCL/images/pixel.gif" class="block" width="1" height="2" border="0" alt="" /></td>
-</tr>
-
-<tr><td>
-<div class="footer">
-<!--Add Department name and email contact here-->
-<p>© ##YEAR## ##COPYRIGHT##<br />
-<!-- Page last updated ##DATE## by ##OWNERNAME##</p> -->
-</div>
-</td>
-</tr>
-</table>
-
-<!-- end footer -->
-</body>
-</html>
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
-<jsp:useBean id="root" scope="application"
- class="org.xenoserver.web.RootBean" />
-<jsp:useBean id="sc" scope="application"
- class="org.xenoserver.web.SystemConfigurationBean" />
-<%@ page session="false" %>
-<%@ page import="org.xenoserver.web.*" %>
-<%@ page import="org.xenoserver.control.*" %>
-<%@ page import="java.util.Iterator" %>
-<%@ page import="java.util.Date" %>
-<%@ page import="java.util.Map.Entry" %>
-<%@ page import="javax.servlet.http.HttpServletRequestWrapper" %>
-
-<html lang="en">
-
-<!--
- THIS FILE HAS BEEN AUTOMATICALLY GENERATED BY A PERL SCRIPT
- THE SOURCE FILE HAS THE EXTENSION .tmpl
--->
-
-
-<head>
-
-<title>##SECTION## ##SECTIONBREAK## ##TITLE##</title>
-
-<link rel="stylesheet" type="text/css" href="xenostyle.css">
-
-</head>
-
-<body bgcolor="#ffffff" text="#000000" link="#003399"
- alink="#cc0000"vlink="#cc3333">
-
-<!-- header -->
-<table cellpadding="0" cellspacing="0" border="0" width="98%" summary="navigation bar">
-<tr>
-<td bgcolor="#0099cc" width="98%" ><img src="img/pixel.gif" class="block" width="1" height="16" alt="" border="0" /></td>
-<td align="right" width="212" rowspan="2" >
-<table cellpadding="0" cellspacing="0" border="0" width="##NAVIGATIONWIDTH##" summary="navigation bar insert">
-<tr>
- ##NAVIGATIONSTRING##
- <td><a href="help.jsp"><img src="img/help.gif" width="53" height="18" border="0" alt="Help" class="block" /></a></td>
-</tr>
-</table>
-</td>
-</tr>
-<tr>
-<td bgcolor="#cccccc" ><img src="img/pixel.gif" class="block"
-width="1" height="2" alt="" border="0" /></td>
-</tr>
-</table>
-<table cellpadding="0" cellspacing="0" border="0" width="98%" summary="departmental header">
-<tr>
-<td><a href="http://www.cam.ac.uk/"><img src="img/cambridge.gif" width="192"
-height="46" border="0" alt="University of Cambridge Home" /></a></td>
-
-<!--Departmental name in next cell-->
-<td align="right" valign="bottom" class="title">##SECTION##<br />##TITLE##</td>
-</tr>
-
-<tr><td bgcolor="#0099cc" colspan="3"><img
-src="img/pixel.gif" class="block" width="1" height="4" alt="" /></td>
-</tr>
-<tr><td bgcolor="#cccccc" colspan="3"><img
-src="img/pixel.gif" class="block" width="1" height="2" alt="" /></td>
-</tr>
-</table>
-<!-- end header -->
-
-<!-- breadcrumbs start -->
-<table cellpadding="0" cellspacing="0" border="0" width="98%" summary="breadcrumb navigation">
-<tr>
-<td><a href="index.jsp"class="bread">XenoServers</a>##BREADCRUMBS##</td>
-</tr>
-</table>
-<!-- end breadcrumbs -->
-
-<!-- body text -->
-<br />
-<!-- <h1>##TITLE##</h1> -->
-<table cellpadding="0" cellspacing="0" border="0" width="98%" summary="content panel">
-<tr>
-<td valign="top">
-<!-- END OF STANDARD HEADER-->
+++ /dev/null
-body {background-color: #ffffff; color: #000000;}
-
-p, ul, ol, li, table, td {font-family: Arial, Helvetica, sans-serif; }
-
-a {text-decoration:none;}
-a:link {color: #003399; font-family: Arial, Helvetica, sans-serif;}
-a:visited {color: #cc3333; font-family: Arial, Helvetica, sans-serif;}
-a:hover {text-decoration: underline; font-family: Arial, Helvetica, sans-serif;}
-a:active {color: #cc0000; font-family: Arial, Helvetica, sans-serif;}
-
-a.bread {font-size: 80%; font-weight: bold;}
-a.univbread {font-size: 90%; font-weight: bold;}
-p.small {font-size: 90%;}
-p.smallc {font-size: 90%; text-align:center; font-weight: bold;}
-p.foot {font-size: 110%; text-align:center;}
-p.nav {font-size: 80%;}
-span.activenav {font-size: 80%; color: #000000}
-
-.bigb {font-size: 110%; font-weight: bold;}
-.small {font-size: 90%;}
-.deptitle {font-size: 140%; color: #000000; font-weight: bold;}
-.deptitle {font-size: 120%; color: #000000; font-weight: bold;}
-.title {font-size: 130%; color: #990000; font-weight: bold;}
-.center {text-align:center;}
-div.footer {font-size: 80%;}
-
-h1 {font-weight: bold; font-size: 120%; color: #990000; font-family: Arial, Helvetica, sans-serif;}
-h2 {font-weight: bold; font-size: 110%; color: #333333; font-family: Arial, Helvetica, sans-serif;}
-h3 {font-weight: bold; font-style: italic; font-size: 100%; color: #333333; font-family: Arial, Helvetica, sans-serif;}
-h4 {font-weight: bold; font-size: 90%; color: #333333; font-family: Arial, Helvetica, sans-serif;}
-h5 {font-weight: bold; font-size: 80%; color: #333333; font-family: Arial, Helvetica, sans-serif;}
-
-
-/* netscape 6 correction */
-.null {font-size: 1px;}
-
-/* linux correction */
-.block {display: block;}
-
-
-/* home page */
-.homeheading {font-weight: bold; font-size: 80%; font-family: arial, helvetica, sans-serif; color: #990000;}
-
-a.homemenu {font-weight: bold; font-family: arial, helvetica, sans-serif;}
-a.homemenu2 {font-size: 80%; font-family: arial, helvetica, sans-serif;}
-
-p.homealert {font-size: 80%; color: #990000; font-family: arial, helvetica, sans-serif;}
-p.homenews {font-size: 80%; font-family: arial, helvetica, sans-serif;}
-
-
-<!--from admin styles-->
-.linkcell { background: #003399; color: #ffffff }
-a.cell { font-family: sans-serif; text-decoration:none }
-a.cell:link { color: #ffffff }
-a.cell:visited { color: #ffffff }
-a.cell:active { color: #ffff33 }
-
-
-.sidemenu {
- /*font-weight : 400; */
- /*font-size : 13px; */
- /*line-height : 12px; */
- /*font-family : Verdana, Arial, Helvetica, sans-serif, "MS sans serif"; */
- /*letter-spacing : 0px; */
- /*text-decoration : none; */
- text-align : left;
-}
-
-.menuheader {
- color : #003366;
- font-weight : bold;
- /*font-size : 13px; */
- /*line-height : 15px; */
- /*font-family : Verdana, Arial, Helvetica, sans-serif, "MS sans serif"; */
- /*letter-spacing : -1px; */
- text-decoration : none;
- text-align : left;
-}
-
-.vdh {
- background-color: #003366;
- color : #ffffff;
- font-weight : bold;
- text-align : center;
-}
-.vdt {
- background-color: #f0f0f0;
-}
-.vds {
- background-color: #aaaaaa;
-}
+++ /dev/null
-#!/bin/bash
-
-if [ -z "$DEFAULTS_FILE" ] ; then DEFAULTS_FILE=xenctl.xml ; fi
-if [ -z "$DEFAULTS_PATH" ] ; then DEFAULTS_PATH=.:/etc:/var/lib/xen ; fi
-if [ -z "$QUERY_DEV" ] ; then QUERY_DEV=eth0 ; fi
-if [ -z "$IFCONFIG" ] ; then IFCONFIG=/sbin/ifconfig ; fi
-if [ -z "$ROUTE" ] ; then ROUTE=/sbin/route ; fi
-if [ -z "$JAVA" ] ; then JAVA=java ; fi
-
-
-ARGS="$XENCTLARGS -DDEFAULTS_FILE=$DEFAULTS_FILE -DDEFAULTS_PATH=$DEFAULTS_PATH"
-
-$JAVA $ARGS -jar $(dirname $0)/xenctl-cmdline.jar $*
+++ /dev/null
-
-CC = gcc
-CFLAGS = -Wall -O3
-CFLAGS += -I../../xen/include -I../../xenolinux-sparse/include
-
-HDRS = $(wildcard *.h)
-SRCS = $(wildcard *.c)
-OBJS = $(patsubst %.c,%.o,$(SRCS))
-
-TARGETS = xi_create xi_start xi_stop xi_destroy xi_build
-TARGETS += xi_phys_grant xi_list xi_save_linux xi_restore_linux
-TARGETS += xi_sched_global xi_sched_domain xi_usage xi_vif_params
-TARGETS += xi_vbd_create xi_vbd_add xi_vbd_list xi_vbd_info
-TARGETS += xi_read_console_ring
-INSTALL = $(TARGETS) xi_vifinit xi_helper
-
-all: check-for-zlib $(TARGETS)
-
-check-for-zlib:
- @if [ ! -e /usr/include/zlib.h ]; then \
- echo "***********************************************************"; \
- echo "ERROR: install zlib header files (http://www.gzip.org/zlib)"; \
- echo "***********************************************************"; \
- false; \
- fi
-
-install: all
- mkdir -p ../../../install/bin
- cp -a $(INSTALL) ../../../install/bin
- chmod 755 ../../../install/bin/xi_vifinit
- chmod 755 ../../../install/bin/xi_helper
-
-clean:
- $(RM) *.o *.rpm $(TARGETS)
-
-rpm: all
- rm -rf staging
- mkdir staging
- mkdir staging/i386
- rpmbuild --define "staging$$PWD/staging" --define '_builddir.' --define "_rpmdir$$PWD/staging" -bb rpm.spec
- mv staging/i386/*.rpm .
- rm -rf staging
-
-xi_build xi_save_linux xi_restore_linux: %: %.c $(HDRS) Makefile
- $(CC) $(CFLAGS) -lz -o $@ $<
-
-%: %.c $(HDRS) Makefile
- $(CC) $(CFLAGS) -o $@ $<
-
+++ /dev/null
-
-#ifndef __DOM0_DEFS_H__
-#define __DOM0_DEFS_H__
-
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <sys/ioctl.h>
-#include <errno.h>
-#include <string.h>
-
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned long u32;
-typedef unsigned long long u64;
-typedef signed char s8;
-typedef signed short s16;
-typedef signed long s32;
-typedef signed long long s64;
-
-#include "mem_defs.h"
-#include <asm-xeno/proc_cmd.h>
-#include <hypervisor-ifs/hypervisor-if.h>
-#include <hypervisor-ifs/dom0_ops.h>
-#include <hypervisor-ifs/vbd.h>
-
-#define ERROR(_m) \
- fprintf(stderr, "ERROR: %s\n", (_m))
-
-#define PERROR(_m) \
- fprintf(stderr, "ERROR: %s (%d = %s)\n", (_m), errno, strerror(errno))
-
-static inline int do_privcmd(unsigned int cmd, unsigned long data)
-{
- int fd, ret;
-
- if ( (fd = open("/proc/xeno/privcmd", O_RDWR)) < 0 )
- {
- PERROR("Could not open proc interface");
- return -1;
- }
-
- if ( (ret = ioctl(fd, cmd, data)) < 0 )
- {
-#ifndef SILENT_ERRORS_FROM_XEN
- PERROR("Error when executing privileged control ioctl");
-#endif
- close(fd);
- return ret;
- }
-
- close(fd);
- return ret;
-}
-
-static inline int do_xen_hypercall(privcmd_hypercall_t *hypercall)
-{
- return do_privcmd(IOCTL_PRIVCMD_HYPERCALL, (unsigned long)hypercall);
-}
-
-static inline int do_dom0_op(dom0_op_t *op)
-{
- int ret = -1;
- privcmd_hypercall_t hypercall;
-
- op->interface_version = DOM0_INTERFACE_VERSION;
-
- hypercall.op = __HYPERVISOR_dom0_op;
- hypercall.arg[0] = (unsigned long)op;
-
- if ( mlock(op, sizeof(*op)) != 0 )
- {
- PERROR("Could not lock memory for Xen hypercall");
- goto out1;
- }
-
- if ( (ret = do_xen_hypercall(&hypercall)) < 0 )
- {
- if ( errno == EACCES )
- fprintf(stderr, "Dom0 operation failed -- need to"
- " rebuild the user-space tool set?\n");
- goto out2;
- }
-
- ret = 0;
-
- out2: (void)munlock(op, sizeof(*op));
- out1: return ret;
-}
-
-static inline int do_network_op(network_op_t *op)
-{
- int ret = -1;
- privcmd_hypercall_t hypercall;
-
- hypercall.op = __HYPERVISOR_network_op;
- hypercall.arg[0] = (unsigned long)op;
-
- if ( mlock(op, sizeof(*op)) != 0 )
- {
- PERROR("Could not lock memory for Xen hypercall");
- goto out1;
- }
-
- if ( (ret = do_xen_hypercall(&hypercall)) < 0 )
- goto out2;
-
- ret = 0;
-
- out2: (void)munlock(op, sizeof(*op));
- out1: return ret;
-}
-
-
-static inline int do_block_io_op(block_io_op_t *op)
-{
- int ret = -1;
- privcmd_hypercall_t hypercall;
-
- hypercall.op = __HYPERVISOR_block_io_op;
- hypercall.arg[0] = (unsigned long)op;
-
- if ( mlock(op, sizeof(*op)) != 0 )
- {
- PERROR("Could not lock memory for Xen hypercall");
- goto out1;
- }
-
- if ( do_xen_hypercall(&hypercall) < 0 )
- goto out2;
-
- ret = 0;
-
- out2: (void)munlock(op, sizeof(*op));
- out1: return ret;
-}
-
-#endif /* __DOM0_DEFS_H__ */
+++ /dev/null
-
-#ifndef __MEM_DEFS_H__
-#define __MEM_DEFS_H__
-
-#define _PAGE_PRESENT 0x001
-#define _PAGE_RW 0x002
-#define _PAGE_USER 0x004
-#define _PAGE_PWT 0x008
-#define _PAGE_PCD 0x010
-#define _PAGE_ACCESSED 0x020
-#define _PAGE_DIRTY 0x040
-#define _PAGE_PAT 0x080
-#define _PAGE_PSE 0x080
-#define _PAGE_GLOBAL 0x100
-
-
-#define L1_PAGETABLE_SHIFT 12
-#define L2_PAGETABLE_SHIFT 22
-
-#define ENTRIES_PER_L1_PAGETABLE 1024
-#define ENTRIES_PER_L2_PAGETABLE 1024
-
-#define PAGE_SHIFT L1_PAGETABLE_SHIFT
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
-
-typedef struct { unsigned long l1_lo; } l1_pgentry_t;
-typedef struct { unsigned long l2_lo; } l2_pgentry_t;
-
-#define l1_table_offset(_a) \
- (((_a) >> L1_PAGETABLE_SHIFT) & (ENTRIES_PER_L1_PAGETABLE - 1))
-#define l2_table_offset(_a) \
- ((_a) >> L2_PAGETABLE_SHIFT)
-
-#endif /* __MEM_DEFS_H__ */
+++ /dev/null
-Summary: Xen command line tools
-Name: xen-internal-tools
-Version: 1.0
-Release: 1
-License: Xen
-Group: Xen
-BuildRoot: %{staging}
-%description
-Command line tools for building and managing domains on a system
-running the Xen hypervisor.
-
-%pre
-%preun
-%install
-install -m 0755 -d $RPM_BUILD_ROOT/bin
-install -m 0755 xi_build $RPM_BUILD_ROOT/bin/xi_build
-install -m 0755 xi_create $RPM_BUILD_ROOT/bin/xi_create
-install -m 0755 xi_destroy $RPM_BUILD_ROOT/bin/xi_destroy
-install -m 0755 xi_helper $RPM_BUILD_ROOT/bin/xi_helper
-install -m 0755 xi_list $RPM_BUILD_ROOT/bin/xi_list
-install -m 0755 xi_start $RPM_BUILD_ROOT/bin/xi_start
-install -m 0755 xi_stop $RPM_BUILD_ROOT/bin/xi_stop
-install -m 0755 xi_vifinit $RPM_BUILD_ROOT/bin/xi_vifinit
-%clean
-%post
-%postun
-%files
-%defattr(-,root,root)
-%dir /bin
-/bin/xi_build
-/bin/xi_create
-/bin/xi_destroy
-/bin/xi_helper
-/bin/xi_list
-/bin/xi_start
-/bin/xi_stop
-/bin/xi_vifinit
+++ /dev/null
-
-#include "dom0_defs.h"
-#include "mem_defs.h"
-
-#include <zlib.h>
-
-/* This string is written to the head of every guest kernel image. */
-#define GUEST_SIG "XenoGues"
-#define SIG_LEN 8
-
-#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
-#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
-
-static unsigned long virt_startinfo_addr;
-
-static char *argv0 = "internal_domain_build";
-
-static long get_tot_pages(int domain_id)
-{
- dom0_op_t op;
- op.cmd = DOM0_GETDOMAININFO;
- op.u.getdomaininfo.domain = domain_id;
- return (do_dom0_op(&op) < 0) ? -1 : op.u.getdomaininfo.tot_pages;
-}
-
-static int get_pfn_list(
- int domain_id, unsigned long *pfn_buf, unsigned long max_pfns)
-{
- dom0_op_t op;
- int ret;
- op.cmd = DOM0_GETMEMLIST;
- op.u.getmemlist.domain = domain_id;
- op.u.getmemlist.max_pfns = max_pfns;
- op.u.getmemlist.buffer = pfn_buf;
-
- if ( mlock(pfn_buf, max_pfns * sizeof(unsigned long)) != 0 )
- {
- PERROR("Could not lock pfn list buffer");
- return -1;
- }
-
- ret = do_dom0_op(&op);
-
- (void)munlock(pfn_buf, max_pfns * sizeof(unsigned long));
-
- return (ret < 0) ? -1 : op.u.getmemlist.num_pfns;
-}
-
-static int send_pgupdates(mmu_update_t *updates, int nr_updates)
-{
- int ret = -1;
- privcmd_hypercall_t hypercall;
-
- hypercall.op = __HYPERVISOR_mmu_update;
- hypercall.arg[0] = (unsigned long)updates;
- hypercall.arg[1] = (unsigned long)nr_updates;
-
- if ( mlock(updates, nr_updates * sizeof(*updates)) != 0 )
- {
- PERROR("Could not lock pagetable update array");
- goto out1;
- }
-
- if ( do_xen_hypercall(&hypercall) < 0 )
- goto out2;
-
- ret = 0;
-
- out2: (void)munlock(updates, nr_updates * sizeof(*updates));
- out1: return ret;
-}
-
-/* Read the kernel header, extracting the image size and load address. */
-static int read_kernel_header(gzFile gfd, long dom_size,
- unsigned long *load_addr)
-{
- char signature[SIG_LEN];
-
- gzread(gfd, signature, SIG_LEN);
- if ( strncmp(signature, GUEST_SIG, SIG_LEN) )
- {
- ERROR("Kernel image does not contain required signature.\n"
- "Terminating.\n");
- return -1;
- }
-
- /* Read the load address which immediately follows the Xeno signature. */
- gzread(gfd, load_addr, sizeof(unsigned long));
-
- return 0;
-}
-
-static int devmem_fd;
-
-static int init_pfn_mapper(void)
-{
- if ( (devmem_fd = open("/dev/mem", O_RDWR)) < 0 )
- {
- PERROR("Could not open /dev/mem");
- return -1;
- }
- return 0;
-}
-
-static void *map_pfn(unsigned long pfn)
-{
- void *vaddr = mmap(NULL, PAGE_SIZE, PROT_READ|PROT_WRITE,
- MAP_SHARED, devmem_fd, pfn << PAGE_SHIFT);
- if ( vaddr == MAP_FAILED )
- {
- PERROR("Could not mmap a domain pfn using /dev/mem");
- return NULL;
- }
- return vaddr;
-}
-
-static void unmap_pfn(void *vaddr)
-{
- (void)munmap(vaddr, PAGE_SIZE);
-}
-
-static int copy_to_domain_page(unsigned long dst_pfn, void *src_page)
-{
- void *vaddr = map_pfn(dst_pfn);
- if ( vaddr == NULL )
- return -1;
- memcpy(vaddr, src_page, PAGE_SIZE);
- unmap_pfn(vaddr);
- return 0;
-}
-
-static int setup_guestos(
- int dom, gzFile kernel_gfd, int initrd_fd, unsigned long tot_pages,
- unsigned long virt_load_addr,
- dom0_builddomain_t *builddomain, int argc, char **argv, int args_start,
- unsigned long shared_info_frame)
-{
- l1_pgentry_t *vl1tab = NULL, *vl1e = NULL;
- l2_pgentry_t *vl2tab = NULL, *vl2e = NULL;
- unsigned long *page_array = NULL;
- mmu_update_t *pgt_update_arr = NULL, *pgt_updates = NULL;
- int alloc_index, num_pt_pages;
- unsigned long l2tab;
- unsigned long l1tab = 0;
- unsigned long num_pgt_updates = 0;
- unsigned long count, pt_start, i, j;
- unsigned long initrd_addr = 0, initrd_len = 0;
- start_info_t *start_info;
- shared_info_t *shared_info;
- int cmd_len;
- unsigned long ksize;
-
- memset(builddomain, 0, sizeof(*builddomain));
-
- if ( init_pfn_mapper() < 0 )
- goto error_out;
-
- pgt_updates = malloc((tot_pages + 1024) * 3 * sizeof(mmu_update_t));
- page_array = malloc(tot_pages * sizeof(unsigned long));
- pgt_update_arr = pgt_updates;
- if ( (pgt_update_arr == NULL) || (page_array == NULL) )
- {
- PERROR("Could not allocate memory");
- goto error_out;
- }
-
- if ( get_pfn_list(dom, page_array, tot_pages) != tot_pages )
- {
- PERROR("Could not get the page frame list");
- goto error_out;
- }
-
- /* Load the guest OS image. Let it take no more than 1/2 memory.*/
- for ( i = 0; i < ((tot_pages/2)*PAGE_SIZE); i += PAGE_SIZE )
- {
- char page[PAGE_SIZE];
- int size;
- if ( (size = gzread(kernel_gfd, page, PAGE_SIZE)) == -1 )
- {
- PERROR("Error reading kernel image, could not"
- " read the whole image.");
- goto error_out;
- }
- if ( size == 0 )
- goto kernel_copied;
- copy_to_domain_page(page_array[i>>PAGE_SHIFT], page);
- }
- ERROR("Kernel too big to safely fit in domain memory");
- goto error_out;
-
- kernel_copied:
- /* ksize is kernel-image size rounded up to a page boundary. */
- ksize = i;
-
- /* Load the initial ramdisk image. */
- if ( initrd_fd >= 0 )
- {
- struct stat stat;
- unsigned long isize;
-
- if ( fstat(initrd_fd, &stat) < 0 )
- {
- PERROR("Could not stat the initrd image");
- goto error_out;
- }
- isize = stat.st_size;
- if ( (isize + ksize) > ((tot_pages/2) * PAGE_SIZE) )
- {
- ERROR("Kernel + initrd too big to safely fit in domain memory");
- goto error_out;
- }
-
- initrd_addr = virt_load_addr + ksize;
- initrd_len = isize;
-
- for ( j = 0, i = ksize; j < isize; j += PAGE_SIZE, i += PAGE_SIZE )
- {
- char page[PAGE_SIZE];
- int size = ((isize-j) < PAGE_SIZE) ? (isize-j) : PAGE_SIZE;
- if ( read(initrd_fd, page, size) != size )
- {
- PERROR("Error reading initrd image, could not"
- " read the whole image.");
- goto error_out;
- }
- copy_to_domain_page(page_array[i>>PAGE_SHIFT], page);
- }
- }
-
- alloc_index = tot_pages - 1;
-
- /* Count bottom-level PTs, rounding up. */
- num_pt_pages = (l1_table_offset(virt_load_addr) + tot_pages + 1023) / 1024;
-
- /* We must also count the page directory. */
- num_pt_pages++;
-
- /* Index of first PT page. */
- pt_start = tot_pages - num_pt_pages;
-
- /*
- * First allocate page for page dir. Allocation goes backwards from the end
- * of the allocated physical address space.
- */
- l2tab = page_array[alloc_index] << PAGE_SHIFT;
- alloc_index--;
- builddomain->ctxt.pt_base = l2tab;
-
- /*
- * Pin down l2tab addr as page dir page - causes hypervisor to provide
- * correct protection for the page
- */
- pgt_updates->ptr = l2tab | MMU_EXTENDED_COMMAND;
- pgt_updates->val = MMUEXT_PIN_L2_TABLE;
- pgt_updates++;
- num_pgt_updates++;
-
- /* Initialise the page tables. */
- if ( (vl2tab = map_pfn(l2tab >> PAGE_SHIFT)) == NULL )
- goto error_out;
- memset(vl2tab, 0, PAGE_SIZE);
- vl2e = vl2tab + l2_table_offset(virt_load_addr);
- for ( count = 0; count < tot_pages; count++ )
- {
- if ( ((unsigned long)vl1e & (PAGE_SIZE-1)) == 0 )
- {
- l1tab = page_array[alloc_index] << PAGE_SHIFT;
- if ( (vl1tab = map_pfn(l1tab >> PAGE_SHIFT)) == NULL )
- goto error_out;
- memset(vl1tab, 0, PAGE_SIZE);
- alloc_index--;
-
- vl1e = vl1tab + l1_table_offset(virt_load_addr +
- (count << PAGE_SHIFT));
-
- /* make apropriate entry in the page directory */
- pgt_updates->ptr = (unsigned long)vl2e;
- pgt_updates->val = l1tab | L2_PROT;
- pgt_updates++;
- num_pgt_updates++;
- vl2e++;
- }
-
- if ( count < pt_start )
- {
- pgt_updates->ptr = (unsigned long)vl1e;
- pgt_updates->val = (page_array[count] << PAGE_SHIFT) | L1_PROT;
- pgt_updates++;
- num_pgt_updates++;
- vl1e++;
- }
- else
- {
- pgt_updates->ptr = (unsigned long)vl1e;
- pgt_updates->val =
- ((page_array[count] << PAGE_SHIFT) | L1_PROT) & ~_PAGE_RW;
- pgt_updates++;
- num_pgt_updates++;
- vl1e++;
- }
-
- pgt_updates->ptr =
- (page_array[count] << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
- pgt_updates->val = count;
- pgt_updates++;
- num_pgt_updates++;
- }
-
- virt_startinfo_addr =
- virt_load_addr + ((alloc_index-1) << PAGE_SHIFT);
-
- start_info = map_pfn(page_array[alloc_index-1]);
- memset(start_info, 0, sizeof(*start_info));
- start_info->pt_base = virt_load_addr + ((tot_pages-1) << PAGE_SHIFT);
- start_info->mod_start = initrd_addr;
- start_info->mod_len = initrd_len;
- start_info->nr_pages = tot_pages;
- start_info->shared_info = shared_info_frame << PAGE_SHIFT;
- start_info->dom_id = dom;
- start_info->flags = 0;
- cmd_len = 0;
- for ( i = args_start; i < argc; i++ )
- {
- if ( cmd_len + strlen(argv[i]) > MAX_CMD_LEN - 1 )
- {
- ERROR("Size of image boot params too big!\n");
- break;
- }
- strcat(start_info->cmd_line, argv[i]);
- strcat(start_info->cmd_line, " ");
- cmd_len += strlen(argv[i] + 1);
- }
- unmap_pfn(start_info);
-
- /* shared_info page starts its life empty. */
- shared_info = map_pfn(shared_info_frame);
- memset(shared_info, 0, PAGE_SIZE);
- unmap_pfn(shared_info);
-
- /* Send the page update requests down to the hypervisor. */
- if ( send_pgupdates(pgt_update_arr, num_pgt_updates) < 0 )
- goto error_out;
-
- free(page_array);
- free(pgt_update_arr);
- return 0;
-
- error_out:
- if ( page_array == NULL )
- free(page_array);
- if ( pgt_update_arr == NULL )
- free(pgt_update_arr);
- return -1;
-}
-
-int main(int argc, char **argv)
-{
- dom0_op_t launch_op, op;
- unsigned long load_addr;
- long tot_pages;
- int kernel_fd, initrd_fd = -1;
- gzFile kernel_gfd;
- int args_start = 4;
- char initrd_name[1024];
- int domain_id;
- int rc, i;
- full_execution_context_t *ctxt;
-
- if ( argv[0] != NULL )
- argv0 = argv[0];
-
- if ( argc < 4 )
- {
- fprintf(stderr, "Usage: %s <domain_id> <image> <num_vifs> "
- "[<initrd=initrd_name>] <boot_params>\n", argv0);
- return 1;
- }
-
- domain_id = atoi(argv[1]);
- if ( domain_id == 0 )
- {
- ERROR("Did you really mean domain 0?");
- return 1;
- }
-
- if ( (tot_pages = get_tot_pages(domain_id)) < 0 )
- {
- PERROR("Could not find total pages for domain");
- return 1;
- }
-
- kernel_fd = open(argv[2], O_RDONLY);
- if ( kernel_fd < 0 )
- {
- PERROR("Could not open kernel image");
- return 1;
- }
-
- if ( (kernel_gfd = gzdopen(kernel_fd, "rb")) == NULL )
- {
- PERROR("Could not allocate decompression state for state file");
- return 1;
- }
-
- rc = read_kernel_header(kernel_gfd,
- tot_pages << (PAGE_SHIFT - 10),
- &load_addr);
- if ( rc < 0 )
- return 1;
-
- if ( (load_addr & (PAGE_SIZE-1)) != 0 )
- {
- ERROR("We can only deal with page-aligned load addresses");
- return -1;
- }
-
- if ( (load_addr + (tot_pages << PAGE_SHIFT)) > HYPERVISOR_VIRT_START )
- {
- ERROR("Cannot map all domain memory without hitting Xen space");
- return -1;
- }
-
- if( (argc > args_start) &&
- (strncmp("initrd=", argv[args_start], 7) == 0) )
- {
- strncpy( initrd_name, argv[args_start]+7, sizeof(initrd_name) );
- initrd_name[sizeof(initrd_name)-1] = 0;
- printf("initrd present, name = %s\n", initrd_name );
- args_start++;
-
- initrd_fd = open(initrd_name, O_RDONLY);
- if ( initrd_fd < 0 )
- {
- PERROR("Could not open the initial ramdisk image");
- return 1;
- }
- }
-
- op.cmd = DOM0_GETDOMAININFO;
- op.u.getdomaininfo.domain = domain_id;
- if ( (do_dom0_op(&op) < 0) || (op.u.getdomaininfo.domain != domain_id) )
- {
- PERROR("Could not get info on domain");
- return 1;
- }
- if ( (op.u.getdomaininfo.state != DOMSTATE_STOPPED) ||
- (op.u.getdomaininfo.ctxt.pt_base != 0) )
- {
- ERROR("Domain is already constructed");
- return 1;
- }
-
- if ( setup_guestos(domain_id, kernel_gfd, initrd_fd, tot_pages,
- load_addr, &launch_op.u.builddomain,
- argc, argv, args_start,
- op.u.getdomaininfo.shared_info_frame) < 0 )
- {
- ERROR("Error constructing guest OS");
- return 1;
- }
-
- if ( initrd_fd >= 0 )
- close(initrd_fd);
- gzclose(kernel_gfd);
-
- ctxt = &launch_op.u.builddomain.ctxt;
-
- ctxt->flags = 0;
-
- /*
- * Initial register values:
- * DS,ES,FS,GS = FLAT_RING1_DS
- * CS:EIP = FLAT_RING1_CS:start_pc
- * SS:ESP = FLAT_RING1_DS:start_stack
- * ESI = start_info
- * [EAX,EBX,ECX,EDX,EDI,EBP are zero]
- * EFLAGS = IF | 2 (bit 1 is reserved and should always be 1)
- */
- ctxt->i386_ctxt.ds = FLAT_RING1_DS;
- ctxt->i386_ctxt.es = FLAT_RING1_DS;
- ctxt->i386_ctxt.fs = FLAT_RING1_DS;
- ctxt->i386_ctxt.gs = FLAT_RING1_DS;
- ctxt->i386_ctxt.ss = FLAT_RING1_DS;
- ctxt->i386_ctxt.cs = FLAT_RING1_CS;
- ctxt->i386_ctxt.eip = load_addr;
- ctxt->i386_ctxt.esp = virt_startinfo_addr;
- ctxt->i386_ctxt.esi = virt_startinfo_addr;
- ctxt->i386_ctxt.eflags = (1<<9) | (1<<2);
-
- /* FPU is set up to default initial state. */
- memset(ctxt->i387_ctxt, 0, sizeof(ctxt->i387_ctxt));
-
- /* Virtual IDT is empty at start-of-day. */
- for ( i = 0; i < 256; i++ )
- {
- ctxt->trap_ctxt[i].vector = i;
- ctxt->trap_ctxt[i].cs = FLAT_RING1_CS;
- }
- ctxt->fast_trap_idx = 0;
-
- /* No LDT. */
- ctxt->ldt_ents = 0;
-
- /* Use the default Xen-provided GDT. */
- ctxt->gdt_ents = 0;
-
- /* Ring 1 stack is the initial stack. */
- ctxt->ring1_ss = FLAT_RING1_DS;
- ctxt->ring1_esp = virt_startinfo_addr;
-
- /* No debugging. */
- memset(ctxt->debugreg, 0, sizeof(ctxt->debugreg));
-
- /* No callback handlers. */
- ctxt->event_callback_cs = FLAT_RING1_CS;
- ctxt->event_callback_eip = 0;
- ctxt->failsafe_callback_cs = FLAT_RING1_CS;
- ctxt->failsafe_callback_eip = 0;
-
- launch_op.u.builddomain.domain = domain_id;
- launch_op.u.builddomain.num_vifs = atoi(argv[3]);
-
- launch_op.cmd = DOM0_BUILDDOMAIN;
- rc = do_dom0_op(&launch_op);
-
- return (rc != 0) ? 1 : 0;
-}
+++ /dev/null
-/*
- * XenoDomainBuilder, copyright (c) Boris Dragovic, bd240@cl.cam.ac.uk
- * This code is released under terms and conditions of GNU GPL :).
- * Usage: <executable> <mem_kb> <os image> <num_vifs>
- */
-
-#include "dom0_defs.h"
-#include "mem_defs.h"
-
-static char *argv0 = "internal_domain_create";
-
-static int create_new_domain(long req_mem, char *name)
-{
- int err;
- dom0_op_t op;
-
- op.cmd = DOM0_CREATEDOMAIN;
- op.u.createdomain.memory_kb = req_mem;
- strncpy(op.u.createdomain.name, name, MAX_DOMAIN_NAME);
- op.u.createdomain.name[MAX_DOMAIN_NAME-1] = '\0';
-
- err = do_dom0_op(&op);
-
- return (err < 0) ? err : op.u.createdomain.domain;
-}
-
-int main(int argc, char **argv)
-{
- int dom_id;
-
- if ( argv[0] != NULL )
- argv0 = argv[0];
-
- if ( argc != 3 )
- {
- fprintf(stderr, "Usage: %s <kbytes-mem> <domain-name>\n", argv0);
- return 1;
- }
-
- dom_id = create_new_domain(atol(argv[1]), argv[2]);
- if ( dom_id < 0 )
- return 1;
-
- printf("%d\n", dom_id);
- return 0;
-}
+++ /dev/null
-
-#include "dom0_defs.h"
-#include "mem_defs.h"
-
-static char *argv0 = "internal_domain_stop";
-
-static int kill_domain(int dom_id, int force)
-{
- int err;
- dom0_op_t op;
-
- op.cmd = DOM0_DESTROYDOMAIN;
- op.u.destroydomain.domain = dom_id;
- op.u.destroydomain.force = force;
-
- err = do_dom0_op(&op);
-
- return (err < 0) ? -1 : 0;
-}
-
-int main(int argc, char **argv)
-{
- int ret, dom;
-
- if ( argv[0] != NULL )
- argv0 = argv[0];
-
- if ( (argc < 2) || (argc > 3) )
- {
- usage:
- fprintf(stderr, "Usage: %s [-f] <domain_id>\n", argv0);
- fprintf(stderr, " -f: Forces immediate destruction of <domain_id>\n");
- return 1;
- }
-
- if ( (argc == 3) && strcmp("-f", argv[1]) )
- goto usage;
-
- dom = atoi(argv[argc-1]);
- if ( dom == 0 )
- {
- ERROR("Did you really mean domain 0?");
- return 1;
- }
-
- ret = kill_domain(dom, argc == 3);
-
- return (ret != 0) ? 1 : 0;
-}
+++ /dev/null
-#!/bin/bash
-
-if [ -z "$QUERY_DEV" ] ; then QUERY_DEV=eth0 ; fi
-
-if [ "$1" = "ip" ] ; then
- /sbin/ifconfig $QUERY_DEV | grep 'inet addr' | tr ':' '\t' | awk '{ print $3}';
-fi
-
-if [ "$1" = "mask" ] ; then
- /sbin/ifconfig $QUERY_DEV | grep 'Mask' | tr ':' '\t' | awk '{print $7}';
-fi
-
-if [ "$1" = "route" ] ; then
- /sbin/route -n | grep $QUERY_DEV | grep 'G' | awk '{print $2}'
-fi
-
-if [ "$1" = "expand" ] ; then
- cd /dev/
- CURRENT=$2
- if [ -h "$CURRENT" ] ; then
- CURRENT=$(basename $(stat -c%N $CURRENT | tr -d "\`\'" | awk '{print $3}'))
- fi
- echo $CURRENT
-fi
\ No newline at end of file
+++ /dev/null
-/******************************************************************************
- * xi_list.c
- *
- * This is a silly little program to dump the currently running domains.
- * The output format is a series of space-separate fields for each domain:
- *
- * 1. Domain id
- * 2. Processor
- * 3. Has CPU (1 => true, 0 => false)
- * 4. State (integer)
- * 5. State (RUNNING, INTERRUPTIBLE, UNINTERRUPTIBLE, WAIT, SUSPENDED, DYING)
- * 6. Pending events (hex value)
- * 7. MCU advance
- * 8. Total pages
- * 9. Name
- */
-
-/*
- * Xen indicates when we've read info on all domains by returning error ESRCH.
- * We don't want the helper functiosn to interpret this as a real error!
- */
-#define SILENT_ERRORS_FROM_XEN
-
-#include "dom0_defs.h"
-#include "mem_defs.h"
-
-static char *argv0 = "internal_domain_list";
-
-static char *statestr(int state)
-{
- switch ( state )
- {
- case DOMSTATE_ACTIVE: return "ACTIVE";
- case DOMSTATE_STOPPED: return "STOPPED";
- default: return "UNKNOWN";
- }
- return NULL;
-}
-
-int main(int argc, char **argv)
-{
- dom0_op_t op;
-
- if ( argv[0] != NULL )
- argv0 = argv[0];
-
- if ( argc != 1 )
- {
- fprintf(stderr, "Usage: %s\n", argv0);
- return 1;
- }
-
- op.cmd = DOM0_GETDOMAININFO;
- op.u.getdomaininfo.domain = 0;
- while ( do_dom0_op(&op) >= 0 )
- {
- printf("%8d %2d %1d %2d %s %08x %8ld %8d %s\n",
- op.u.getdomaininfo.domain,
- op.u.getdomaininfo.processor,
- op.u.getdomaininfo.has_cpu,
- op.u.getdomaininfo.state,
- statestr(op.u.getdomaininfo.state),
- op.u.getdomaininfo.hyp_events,
- op.u.getdomaininfo.mcu_advance,
- op.u.getdomaininfo.tot_pages,
- op.u.getdomaininfo.name);
- op.u.getdomaininfo.domain++;
- }
-
- return 0;
-}
+++ /dev/null
-
-#define _GNU_SOURCE
-#include "dom0_defs.h"
-
-
-int main(int argc, char *argv[])
-{
- block_io_op_t op;
- unsigned int domain;
- unsigned short vdevice, device;
- int ret;
-
- if ( argc != 7 )
- {
- fprintf(stderr, "Usage: xi_physdev_grant_new <r/rw> <domain> "
- "<device> <start sector> <n_sectors> <partition>\n");
- return 1;
- }
-
-
- /*
- ** XXX SMH: guests can refer to 'real' devices as anything; however
- ** for this particular use ("physdisk access") we want to use the
- ** same device number in the guest as is used in xen => both 'vdevice'
- ** (XL name) and "device" (Xen name) are the same.
- */
- domain = atoi(argv[2]);
- device = atoi(argv[3]);
- /* XXX SMH: hack -- generate device name by addition ptn number */
- vdevice = device + atoi(argv[6]);
-
- op.cmd = BLOCK_IO_OP_VBD_CREATE;
- op.u.create_params.domain = domain;
- op.u.create_params.vdevice = vdevice;
- op.u.create_params.mode = 0;
- if ( strchr(argv[1], 'r') )
- op.u.create_params.mode |= VBD_MODE_R;
- if ( strchr(argv[1], 'w') )
- op.u.create_params.mode |= VBD_MODE_W;
-
- ret = do_block_io_op(&op);
-
- if(ret < 0) {
- fprintf(stderr, "error %d attempting to create VBD %04x\n", ret,
- atoi(argv[2]));
- return ret;
- }
-
-
- op.cmd = BLOCK_IO_OP_VBD_ADD;
- op.u.add_params.domain = domain;
- op.u.add_params.vdevice = vdevice;
-
- op.u.add_params.extent.device = device;
- op.u.add_params.extent.start_sector = atol(argv[4]);
- op.u.add_params.extent.nr_sectors = atol(argv[5]);
-
- ret = do_block_io_op(&op);
-
- if(ret < 0) {
- fprintf(stderr, "error %d attempting to add extent to VBD %04x\n",
- ret, atoi(argv[2]));
- return ret;
- }
-
- return 0;
-}
+++ /dev/null
-/*
- * Usage: <executable> [-c]
- */
-
-#include "dom0_defs.h"
-
-#define CONSOLE_RING_SIZE 16392
-#define CONSOLE_RING_CLEAR 1
-
-static char *argv0 = "read_console_ring";
-
-static long read_console_ring(unsigned long str, unsigned count, unsigned int cmd)
-{
- int ret;
- dom0_op_t op;
-
- op.cmd = DOM0_READCONSOLE;
- op.u.readconsole.str = str;
- op.u.readconsole.count = count;
- op.u.readconsole.cmd = cmd;
-
- ret = do_dom0_op(&op);
- if (ret > 0) {
- *((char *)str + ret) = '\0';
- }
-
- return ret;
-}
-
-int main(int argc, char **argv)
-{
- char str[CONSOLE_RING_SIZE+1];
- unsigned int cmd = 0;
-
- if ( argv[0] != NULL )
- argv0 = argv[0];
-
- if ( argc > 2 || (argc == 2 && strcmp(argv[1], "-c")) ) {
- fprintf(stderr, "Usage: %s [-c]\n", argv0);
- return 1;
- }
-
- if ( argc == 2) {
- cmd |= CONSOLE_RING_CLEAR;
- }
-
- if ( mlock(str, CONSOLE_RING_SIZE+1) != 0) {
- PERROR("Could not lock memory for user space read console ring buffer");
- return 1;
- }
-
- if ( read_console_ring((unsigned long)str, CONSOLE_RING_SIZE, cmd) < 0 ) {
- printf("Read console ring error.\n");
- return 1;
- }
-
- printf("%s", str);
-
- return 0;
-}
+++ /dev/null
-/******************************************************************************
- * xi_restore_linux.c
- *
- * Restore the state of a Xenolinux session.
- *
- * Copyright (c) 2003, K A Fraser.
- */
-
-#include "dom0_defs.h"
-#include "mem_defs.h"
-#include <asm-xeno/suspend.h>
-
-#include <zlib.h>
-
-static char *argv0 = "internal_restore_linux";
-
-/* A table mapping each PFN to its new MFN. */
-static unsigned long *pfn_to_mfn_table;
-
-/* This may allow us to create a 'quiet' command-line option, if necessary. */
-#define verbose_printf(_f, _a...) \
- do { \
- printf( _f , ## _a ); \
- fflush(stdout); \
- } while ( 0 )
-
-static int get_pfn_list(
- int domain_id, unsigned long *pfn_buf, unsigned long max_pfns)
-{
- dom0_op_t op;
- int ret;
- op.cmd = DOM0_GETMEMLIST;
- op.u.getmemlist.domain = domain_id;
- op.u.getmemlist.max_pfns = max_pfns;
- op.u.getmemlist.buffer = pfn_buf;
-
- if ( mlock(pfn_buf, max_pfns * sizeof(unsigned long)) != 0 )
- {
- PERROR("Could not lock pfn list buffer");
- return -1;
- }
-
- ret = do_dom0_op(&op);
-
- (void)munlock(pfn_buf, max_pfns * sizeof(unsigned long));
-
- return (ret < 0) ? -1 : op.u.getmemlist.num_pfns;
-}
-
-#define MAX_MMU_UPDATES 1024
-static mmu_update_t mmu_updates[MAX_MMU_UPDATES];
-static int mmu_update_idx;
-
-static int flush_mmu_updates(void)
-{
- int err = 0;
- privcmd_hypercall_t hypercall;
-
- if ( mmu_update_idx == 0 )
- return 0;
-
- hypercall.op = __HYPERVISOR_mmu_update;
- hypercall.arg[0] = (unsigned long)mmu_updates;
- hypercall.arg[1] = (unsigned long)mmu_update_idx;
-
- if ( mlock(mmu_updates, sizeof(mmu_updates)) != 0 )
- {
- PERROR("Could not lock pagetable update array");
- err = 1;
- goto out;
- }
-
- if ( do_xen_hypercall(&hypercall) < 0 )
- {
- ERROR("Failure when submitting mmu updates");
- err = 1;
- }
-
- mmu_update_idx = 0;
-
- (void)munlock(mmu_updates, sizeof(mmu_updates));
-
- out:
- return err;
-}
-
-static int add_mmu_update(unsigned long ptr, unsigned long val)
-{
- mmu_updates[mmu_update_idx].ptr = ptr;
- mmu_updates[mmu_update_idx].val = val;
- if ( ++mmu_update_idx == MAX_MMU_UPDATES )
- return flush_mmu_updates();
- return 0;
-}
-
-static int devmem_fd;
-
-static int init_pfn_mapper(void)
-{
- if ( (devmem_fd = open("/dev/mem", O_RDWR)) < 0 )
- {
- PERROR("Could not open /dev/mem");
- return -1;
- }
- return 0;
-}
-
-static void *map_pfn(unsigned long pfn)
-{
- void *vaddr = mmap(NULL, PAGE_SIZE, PROT_READ|PROT_WRITE,
- MAP_SHARED, devmem_fd, pfn << PAGE_SHIFT);
- if ( vaddr == MAP_FAILED )
- {
- PERROR("Could not mmap a domain pfn using /dev/mem");
- return NULL;
- }
- return vaddr;
-}
-
-static void unmap_pfn(void *vaddr)
-{
- (void)munmap(vaddr, PAGE_SIZE);
-}
-
-static int checked_read(gzFile fd, void *buf, size_t count)
-{
- int rc;
- while ( ((rc = gzread(fd, buf, count)) == -1) && (errno == EINTR) )
- continue;
- return rc == count;
-}
-
-int main(int argc, char **argv)
-{
- dom0_op_t op;
- int rc = 1, i, j;
- unsigned long mfn, pfn, dom = 0;
- unsigned int prev_pc, this_pc;
-
- /* Number of page frames in use by this XenoLinux session. */
- unsigned long nr_pfns;
-
- /* The new domain's shared-info frame number. */
- unsigned long shared_info_frame;
- unsigned char shared_info[PAGE_SIZE]; /* saved contents from file */
-
- /* A copy of the CPU context of the guest. */
- full_execution_context_t ctxt;
-
- /* First 16 bytes of the state file must contain 'XenoLinuxSuspend'. */
- char signature[16];
-
- /* A copy of the domain's name. */
- char name[MAX_DOMAIN_NAME];
-
- /* A table containg the type of each PFN (/not/ MFN!). */
- unsigned long *pfn_type;
-
- /* A temporary mapping, and a copy, of one frame of guest memory. */
- unsigned long *ppage, page[1024];
-
- /* A copy of the pfn-to-mfn table frame list. */
- unsigned long pfn_to_mfn_frame_list[1024];
-
- /* A temporary mapping of the guest's suspend record. */
- suspend_record_t *p_srec;
-
- /* The name and descriptor of the file that we are reading from. */
- char *filename;
- int fd;
- gzFile gfd;
-
- if ( argv[0] != NULL )
- argv0 = argv[0];
-
- if ( argc != 2 )
- {
- fprintf(stderr, "Usage: %s <state file>\n", argv0);
- return 1;
- }
-
- filename = argv[1];
- if ( (fd = open(filename, O_RDONLY)) == -1 )
- {
- PERROR("Could not open state file for reading");
- return 1;
- }
-
- if ( (gfd = gzdopen(fd, "rb")) == NULL )
- {
- ERROR("Could not allocate decompression state for state file");
- close(fd);
- return 1;
- }
-
- /* Start writing out the saved-domain record. */
- if ( !checked_read(gfd, signature, 16) ||
- (memcmp(signature, "XenoLinuxSuspend", 16) != 0) )
- {
- ERROR("Unrecognised state format -- no signature found");
- goto out;
- }
-
- if ( !checked_read(gfd, name, sizeof(name)) ||
- !checked_read(gfd, &nr_pfns, sizeof(unsigned long)) ||
- !checked_read(gfd, &ctxt, sizeof(ctxt)) ||
- !checked_read(gfd, shared_info, PAGE_SIZE) ||
- !checked_read(gfd, pfn_to_mfn_frame_list, PAGE_SIZE) )
- {
- ERROR("Error when reading from state file");
- goto out;
- }
-
- for ( i = 0; i < MAX_DOMAIN_NAME; i++ )
- {
- if ( name[i] == '\0' ) break;
- if ( name[i] & 0x80 )
- {
- ERROR("Random characters in domain name");
- goto out;
- }
- }
- name[MAX_DOMAIN_NAME-1] = '\0';
-
- if ( nr_pfns > 1024*1024 )
- {
- ERROR("Invalid state file -- pfn count out of range");
- goto out;
- }
-
- /* We want zeroed memory so use calloc rather than malloc. */
- pfn_to_mfn_table = calloc(1, 4 * nr_pfns);
- pfn_type = calloc(1, 4 * nr_pfns);
-
- if ( !checked_read(gfd, pfn_type, 4 * nr_pfns) )
- {
- ERROR("Error when reading from state file");
- goto out;
- }
-
- /* Create a new domain of the appropriate size, and find it's dom_id. */
- op.cmd = DOM0_CREATEDOMAIN;
- op.u.createdomain.memory_kb = nr_pfns * (PAGE_SIZE / 1024);
- memcpy(op.u.createdomain.name, name, MAX_DOMAIN_NAME);
- if ( do_dom0_op(&op) < 0 )
- {
- ERROR("Could not create new domain");
- goto out;
- }
- dom = op.u.createdomain.domain;
-
- /* Get the domain's shared-info frame. */
- op.cmd = DOM0_GETDOMAININFO;
- op.u.getdomaininfo.domain = dom;
- if ( do_dom0_op(&op) < 0 )
- {
- ERROR("Could not get information on new domain");
- goto out;
- }
- shared_info_frame = op.u.getdomaininfo.shared_info_frame;
-
- if ( init_pfn_mapper() < 0 )
- goto out;
-
- /* Copy saved contents of shared-info page. No checking needed. */
- ppage = map_pfn(shared_info_frame);
- memcpy(ppage, shared_info, PAGE_SIZE);
- unmap_pfn(ppage);
-
- /* Build the pfn-to-mfn table. We choose MFN ordering returned by Xen. */
- if ( get_pfn_list(dom, pfn_to_mfn_table, nr_pfns) != nr_pfns )
- {
- ERROR("Did not read correct number of frame numbers for new dom");
- goto out;
- }
-
- verbose_printf("Reloading memory pages: 0%%");
-
- /*
- * Now simply read each saved frame into its new machine frame.
- * We uncanonicalise page tables as we go.
- */
- prev_pc = 0;
- for ( i = 0; i < nr_pfns; i++ )
- {
- this_pc = (i * 100) / nr_pfns;
- if ( (this_pc - prev_pc) >= 5 )
- {
- verbose_printf("\b\b\b\b%3d%%", this_pc);
- prev_pc = this_pc;
- }
-
- mfn = pfn_to_mfn_table[i];
-
- if ( !checked_read(gfd, page, PAGE_SIZE) )
- {
- ERROR("Error when reading from state file");
- goto out;
- }
-
- ppage = map_pfn(mfn);
- switch ( pfn_type[i] )
- {
- case L1TAB:
- memset(ppage, 0, PAGE_SIZE);
- if ( add_mmu_update((mfn<<PAGE_SHIFT) | MMU_EXTENDED_COMMAND,
- MMUEXT_PIN_L1_TABLE) )
- goto out;
- for ( j = 0; j < 1024; j++ )
- {
- if ( page[j] & _PAGE_PRESENT )
- {
- if ( (pfn = page[j] >> PAGE_SHIFT) >= nr_pfns )
- {
- ERROR("Frame number in page table is out of range");
- goto out;
- }
- if ( (pfn_type[pfn] != NONE) && (page[j] & _PAGE_RW) )
- {
- ERROR("Write access requested for a restricted frame");
- goto out;
- }
- page[j] &= (PAGE_SIZE - 1) & ~(_PAGE_GLOBAL | _PAGE_PAT);
- page[j] |= pfn_to_mfn_table[pfn] << PAGE_SHIFT;
- }
- if ( add_mmu_update((unsigned long)&ppage[j], page[j]) )
- goto out;
- }
- break;
- case L2TAB:
- memset(ppage, 0, PAGE_SIZE);
- if ( add_mmu_update((mfn<<PAGE_SHIFT) | MMU_EXTENDED_COMMAND,
- MMUEXT_PIN_L2_TABLE) )
- goto out;
- for ( j = 0; j < (HYPERVISOR_VIRT_START>>L2_PAGETABLE_SHIFT); j++ )
- {
- if ( page[j] & _PAGE_PRESENT )
- {
- if ( (pfn = page[j] >> PAGE_SHIFT) >= nr_pfns )
- {
- ERROR("Frame number in page table is out of range");
- goto out;
- }
- if ( pfn_type[pfn] != L1TAB )
- {
- ERROR("Page table mistyping");
- goto out;
- }
- /* Haven't reached the L1 table yet. Ensure it is safe! */
- if ( pfn > i )
- {
- unsigned long **l1 = map_pfn(pfn_to_mfn_table[pfn]);
- memset(l1, 0, PAGE_SIZE);
- unmap_pfn(l1);
- }
- page[j] &= (PAGE_SIZE - 1) & ~(_PAGE_GLOBAL | _PAGE_PSE);
- page[j] |= pfn_to_mfn_table[pfn] << PAGE_SHIFT;
- }
- if ( add_mmu_update((unsigned long)&ppage[j], page[j]) )
- goto out;
- }
- break;
- default:
- memcpy(ppage, page, PAGE_SIZE);
- break;
- }
- /* NB. Must flush before unmapping page, as pass VAs to Xen. */
- if ( flush_mmu_updates() )
- goto out;
- unmap_pfn(ppage);
-
- if ( add_mmu_update((mfn<<PAGE_SHIFT) | MMU_MACHPHYS_UPDATE, i) )
- goto out;
- }
-
- if ( flush_mmu_updates() )
- goto out;
-
- verbose_printf("\b\b\b\b100%%\nMemory reloaded.\n");
-
- /* Uncanonicalise the suspend-record frame number and poke resume rec. */
- pfn = ctxt.i386_ctxt.esi;
- if ( (pfn >= nr_pfns) || (pfn_type[pfn] != NONE) )
- {
- ERROR("Suspend record frame number is bad");
- goto out;
- }
- ctxt.i386_ctxt.esi = mfn = pfn_to_mfn_table[pfn];
- p_srec = map_pfn(mfn);
- p_srec->resume_info.nr_pages = nr_pfns;
- p_srec->resume_info.shared_info = shared_info_frame << PAGE_SHIFT;
- p_srec->resume_info.dom_id = dom;
- p_srec->resume_info.flags = 0;
- unmap_pfn(p_srec);
-
- /* Uncanonicalise each GDT frame number. */
- if ( ctxt.gdt_ents > 8192 )
- {
- ERROR("GDT entry count out of range");
- goto out;
- }
- for ( i = 0; i < ctxt.gdt_ents; i += 512 )
- {
- pfn = ctxt.gdt_frames[i];
- if ( (pfn >= nr_pfns) || (pfn_type[pfn] != NONE) )
- {
- ERROR("GDT frame number is bad");
- goto out;
- }
- ctxt.gdt_frames[i] = pfn_to_mfn_table[pfn];
- }
-
- /* Uncanonicalise the page table base pointer. */
- pfn = ctxt.pt_base >> PAGE_SHIFT;
- if ( (pfn >= nr_pfns) || (pfn_type[pfn] != L2TAB) )
- {
- ERROR("PT base is bad");
- goto out;
- }
- ctxt.pt_base = pfn_to_mfn_table[pfn] << PAGE_SHIFT;
-
- /* Uncanonicalise the pfn-to-mfn table frame-number list. */
- for ( i = 0; i < nr_pfns; i += 1024 )
- {
- unsigned long copy_size = (nr_pfns - i) * sizeof(unsigned long);
- if ( copy_size > PAGE_SIZE ) copy_size = PAGE_SIZE;
- pfn = pfn_to_mfn_frame_list[i/1024];
- if ( (pfn >= nr_pfns) || (pfn_type[pfn] != NONE) )
- {
- ERROR("PFN-to-MFN frame number is bad");
- goto out;
- }
- ppage = map_pfn(pfn_to_mfn_table[pfn]);
- memcpy(ppage, &pfn_to_mfn_table[i], copy_size);
- unmap_pfn(ppage);
- }
-
- /*
- * Safety checking of saved context:
- * 1. i386_ctxt is fine, as Xen checks that on context switch.
- * 2. i387_ctxt is fine, as it can't hurt Xen.
- * 3. trap_ctxt needs the code selectors checked.
- * 4. fast_trap_idx is checked by Xen.
- * 5. ldt base must be page-aligned, no more than 8192 ents, ...
- * 6. gdt already done, and further checking is done by Xen.
- * 7. check that ring1_ss is safe.
- * 8. pt_base is already done.
- * 9. debugregs are checked by Xen.
- * 10. callback code selectors need checking.
- */
- for ( i = 0; i < 256; i++ )
- {
- ctxt.trap_ctxt[i].vector = i;
- if ( (ctxt.trap_ctxt[i].cs & 3) == 0 )
- ctxt.trap_ctxt[i].cs = FLAT_RING1_CS;
- }
- if ( (ctxt.ring1_ss & 3) == 0 )
- ctxt.ring1_ss = FLAT_RING1_DS;
- if ( (ctxt.event_callback_cs & 3) == 0 )
- ctxt.event_callback_cs = FLAT_RING1_CS;
- if ( (ctxt.failsafe_callback_cs & 3) == 0 )
- ctxt.failsafe_callback_cs = FLAT_RING1_CS;
- if ( ((ctxt.ldt_base & (PAGE_SIZE - 1)) != 0) ||
- (ctxt.ldt_ents > 8192) ||
- (ctxt.ldt_base > HYPERVISOR_VIRT_START) ||
- ((ctxt.ldt_base + ctxt.ldt_ents*8) > HYPERVISOR_VIRT_START) )
- {
- ERROR("Bad LDT base or size");
- goto out;
- }
-
- op.cmd = DOM0_BUILDDOMAIN;
- op.u.builddomain.domain = dom;
- op.u.builddomain.num_vifs = 1;
- memcpy(&op.u.builddomain.ctxt, &ctxt, sizeof(ctxt));
- rc = do_dom0_op(&op);
-
- out:
- if ( rc != 0 )
- {
- if ( dom != 0 )
- {
- op.cmd = DOM0_DESTROYDOMAIN;
- op.u.destroydomain.domain = dom;
- op.u.destroydomain.force = 1;
- (void)do_dom0_op(&op);
- }
- }
- else
- {
- /* Success: print the domain id. */
- printf("DOM=%ld\n", dom);
- }
-
- gzclose(gfd);
-
- return !!rc;
-}
+++ /dev/null
-/******************************************************************************
- * xi_save_linux.c
- *
- * Save the state of a running Xenolinux session.
- *
- * Copyright (c) 2003, K A Fraser.
- */
-
-#include "dom0_defs.h"
-#include "mem_defs.h"
-#include <asm-xeno/suspend.h>
-
-#include <zlib.h>
-
-static char *argv0 = "internal_save_linux";
-
-/* A table mapping each PFN to its current MFN. */
-static unsigned long *pfn_to_mfn_table;
-/* A table mapping each current MFN to its canonical PFN. */
-static unsigned long *mfn_to_pfn_table;
-
-/* This may allow us to create a 'quiet' command-line option, if necessary. */
-#define verbose_printf(_f, _a...) \
- do { \
- printf( _f , ## _a ); \
- fflush(stdout); \
- } while ( 0 )
-
-static int devmem_fd;
-
-static int init_pfn_mapper(void)
-{
- if ( (devmem_fd = open("/dev/mem", O_RDWR)) < 0 )
- {
- PERROR("Could not open /dev/mem");
- return -1;
- }
- return 0;
-}
-
-static void *map_pfn(unsigned long pfn)
-{
- void *vaddr = mmap(NULL, PAGE_SIZE, PROT_READ|PROT_WRITE,
- MAP_SHARED, devmem_fd, pfn << PAGE_SHIFT);
- if ( vaddr == MAP_FAILED )
- {
- PERROR("Could not mmap a domain pfn using /dev/mem");
- return NULL;
- }
- return vaddr;
-}
-
-static void unmap_pfn(void *vaddr)
-{
- (void)munmap(vaddr, PAGE_SIZE);
-}
-
-/*
- * Returns TRUE if the given machine frame number has a unique mapping
- * in the guest's pseudophysical map.
- */
-#define MFN_IS_IN_PSEUDOPHYS_MAP(_mfn) \
- (((_mfn) < (1024*1024)) && \
- (pfn_to_mfn_table[mfn_to_pfn_table[_mfn]] == (_mfn)))
-
-/* Returns TRUE if MFN is successfully converted to a PFN. */
-static int translate_mfn_to_pfn(unsigned long *pmfn)
-{
- unsigned long mfn = *pmfn;
- if ( !MFN_IS_IN_PSEUDOPHYS_MAP(mfn) )
- return 0;
- *pmfn = mfn_to_pfn_table[mfn];
- return 1;
-}
-
-static int check_pfn_ownership(unsigned long mfn, unsigned int dom)
-{
- dom0_op_t op;
- op.cmd = DOM0_GETPAGEFRAMEINFO;
- op.u.getpageframeinfo.pfn = mfn;
- if ( (do_dom0_op(&op) < 0) || (op.u.getpageframeinfo.domain != dom) )
- return 0;
- return 1;
-}
-
-static unsigned int get_pfn_type(unsigned long mfn)
-{
- dom0_op_t op;
- op.cmd = DOM0_GETPAGEFRAMEINFO;
- op.u.getpageframeinfo.pfn = mfn;
- if ( do_dom0_op(&op) < 0 )
- {
- PERROR("Unexpected failure when getting page frame info!");
- exit(1);
- }
- return op.u.getpageframeinfo.type;
-}
-
-static int checked_write(gzFile fd, void *buf, size_t count)
-{
- int rc;
- while ( ((rc = gzwrite(fd, buf, count)) == -1) && (errno = EINTR) )
- continue;
- return rc == count;
-}
-
-int main(int argc, char **argv)
-{
- dom0_op_t op;
- int rc = 1, i, j;
- unsigned long mfn, dom;
- unsigned int prev_pc, this_pc;
-
- /* Remember if we stopped the guest, so we can restart it on exit. */
- int we_stopped_it = 0;
-
- /* The new domain's shared-info frame number. */
- unsigned long shared_info_frame;
-
- /* A copy of the CPU context of the guest. */
- full_execution_context_t ctxt;
-
- /* A copy of the domain's name. */
- char name[MAX_DOMAIN_NAME];
-
- /* A table containg the type of each PFN (/not/ MFN!). */
- unsigned long *pfn_type;
-
- /* A temporary mapping, and a copy, of one frame of guest memory. */
- unsigned long *ppage, page[1024];
-
- /* A temporary mapping, and a copy, of the pfn-to-mfn table frame list. */
- unsigned long *p_pfn_to_mfn_frame_list, pfn_to_mfn_frame_list[1024];
- /* A temporary mapping of one frame in the above list. */
- unsigned long *pfn_to_mfn_frame;
-
- /* A temporary mapping, and a copy, of the guest's suspend record. */
- suspend_record_t *p_srec, srec;
-
- /* The name and descriptor of the file that we are writing to. */
- char *filename;
- int fd;
- gzFile gfd;
-
- if ( argv[0] != NULL )
- argv0 = argv[0];
-
- if ( argc != 3 )
- {
- fprintf(stderr, "Usage: %s <domain_id> <state file>\n", argv0);
- return 1;
- }
-
- dom = atoi(argv[1]);
- if ( dom == 0 )
- {
- ERROR("Did you really mean domain 0?");
- return 1;
- }
-
- filename = argv[2];
- if ( (fd = open(filename, O_CREAT|O_EXCL|O_WRONLY, 0644)) == -1 )
- {
- PERROR("Could not open file for writing");
- return 1;
- }
-
- /*
- * Compression rate 1: we want speed over compression. We're mainly going
- * for those zero pages, after all.
- */
- if ( (gfd = gzdopen(fd, "wb1")) == NULL )
- {
- ERROR("Could not allocate compression state for state file");
- close(fd);
- return 1;
- }
-
- /* Ensure that the domain exists, and that it is stopped. */
- for ( ; ; )
- {
- op.cmd = DOM0_GETDOMAININFO;
- op.u.getdomaininfo.domain = dom;
- if ( (do_dom0_op(&op) < 0) || (op.u.getdomaininfo.domain != dom) )
- {
- PERROR("Could not get info on domain");
- goto out;
- }
-
- memcpy(&ctxt, &op.u.getdomaininfo.ctxt, sizeof(ctxt));
- memcpy(name, op.u.getdomaininfo.name, sizeof(name));
- shared_info_frame = op.u.getdomaininfo.shared_info_frame;
-
- if ( op.u.getdomaininfo.state == DOMSTATE_STOPPED )
- break;
-
- we_stopped_it = 1;
-
- op.cmd = DOM0_STOPDOMAIN;
- op.u.stopdomain.domain = dom;
- (void)do_dom0_op(&op);
-
- sleep(1);
- }
-
- /* A cheesy test to see whether the domain contains valid state. */
- if ( ctxt.pt_base == 0 )
- {
- ERROR("Domain is not in a valid Xenolinux state");
- goto out;
- }
-
- if ( init_pfn_mapper() < 0 )
- goto out;
-
- /* Is the suspend-record MFN actually valid for this domain? */
- if ( !check_pfn_ownership(ctxt.i386_ctxt.esi, dom) )
- {
- ERROR("Invalid state record pointer");
- goto out;
- }
-
- /* If the suspend-record MFN is okay then grab a copy of it to @srec. */
- p_srec = map_pfn(ctxt.i386_ctxt.esi);
- memcpy(&srec, p_srec, sizeof(srec));
- unmap_pfn(p_srec);
-
- if ( srec.nr_pfns > 1024*1024 )
- {
- ERROR("Invalid state record -- pfn count out of range");
- goto out;
- }
-
- if ( !check_pfn_ownership(srec.pfn_to_mfn_frame_list, dom) )
- {
- ERROR("Invalid pfn-to-mfn frame list pointer");
- goto out;
- }
-
- /* Grab a copy of the pfn-to-mfn table frame list. */
- p_pfn_to_mfn_frame_list = map_pfn(srec.pfn_to_mfn_frame_list);
- memcpy(pfn_to_mfn_frame_list, p_pfn_to_mfn_frame_list, PAGE_SIZE);
- unmap_pfn(p_pfn_to_mfn_frame_list);
-
- /* We want zeroed memory so use calloc rather than malloc. */
- mfn_to_pfn_table = calloc(1, 4 * 1024 * 1024);
- pfn_to_mfn_table = calloc(1, 4 * srec.nr_pfns);
- pfn_type = calloc(1, 4 * srec.nr_pfns);
-
- /*
- * Construct the local pfn-to-mfn and mfn-to-pfn tables. On exit from this
- * loop we have each MFN mapped at most once. Note that there may be MFNs
- * that aren't mapped at all: we detect these by MFN_IS_IN_PSEUDOPHYS_MAP.
- */
- pfn_to_mfn_frame = NULL;
- for ( i = 0; i < srec.nr_pfns; i++ )
- {
- /* Each frameful of table frames must be checked & mapped on demand. */
- if ( (i & 1023) == 0 )
- {
- mfn = pfn_to_mfn_frame_list[i/1024];
- if ( !check_pfn_ownership(mfn, dom) )
- {
- ERROR("Invalid frame number if pfn-to-mfn frame list");
- goto out;
- }
- if ( pfn_to_mfn_frame != NULL )
- unmap_pfn(pfn_to_mfn_frame);
- pfn_to_mfn_frame = map_pfn(mfn);
- }
-
- mfn = pfn_to_mfn_frame[i & 1023];
-
- if ( !check_pfn_ownership(mfn, dom) )
- {
- ERROR("Invalid frame specified with pfn-to-mfn table");
- goto out;
- }
-
- /* Did we map this MFN already? That would be invalid! */
- if ( MFN_IS_IN_PSEUDOPHYS_MAP(mfn) )
- {
- ERROR("A machine frame appears twice in pseudophys space");
- goto out;
- }
-
- pfn_to_mfn_table[i] = mfn;
- mfn_to_pfn_table[mfn] = i;
-
- /* Query page type by MFN, but store it by PFN. */
- pfn_type[i] = get_pfn_type(mfn);
- }
-
- /* Canonicalise the suspend-record frame number. */
- if ( !translate_mfn_to_pfn(&ctxt.i386_ctxt.esi) )
- {
- ERROR("State record is not in range of pseudophys map");
- goto out;
- }
-
- /* Canonicalise each GDT frame number. */
- for ( i = 0; i < ctxt.gdt_ents; i += 512 )
- {
- if ( !translate_mfn_to_pfn(&ctxt.gdt_frames[i]) )
- {
- ERROR("GDT frame is not in range of pseudophys map");
- goto out;
- }
- }
-
- /* Canonicalise the page table base pointer. */
- if ( !MFN_IS_IN_PSEUDOPHYS_MAP(ctxt.pt_base >> PAGE_SHIFT) )
- {
- ERROR("PT base is not in range of pseudophys map");
- goto out;
- }
- ctxt.pt_base = mfn_to_pfn_table[ctxt.pt_base >> PAGE_SHIFT] << PAGE_SHIFT;
-
- /* Canonicalise the pfn-to-mfn table frame-number list. */
- for ( i = 0; i < srec.nr_pfns; i += 1024 )
- {
- if ( !translate_mfn_to_pfn(&pfn_to_mfn_frame_list[i/1024]) )
- {
- ERROR("Frame # in pfn-to-mfn frame list is not in pseudophys");
- goto out;
- }
- }
-
- /* Start writing out the saved-domain record. */
- ppage = map_pfn(shared_info_frame);
- if ( !checked_write(gfd, "XenoLinuxSuspend", 16) ||
- !checked_write(gfd, name, sizeof(name)) ||
- !checked_write(gfd, &srec.nr_pfns, sizeof(unsigned long)) ||
- !checked_write(gfd, &ctxt, sizeof(ctxt)) ||
- !checked_write(gfd, ppage, PAGE_SIZE) ||
- !checked_write(gfd, pfn_to_mfn_frame_list, PAGE_SIZE) ||
- !checked_write(gfd, pfn_type, 4 * srec.nr_pfns) )
- {
- ERROR("Error when writing to state file");
- goto out;
- }
- unmap_pfn(ppage);
-
- verbose_printf("Saving memory pages: 0%%");
-
- /* Now write out each data page, canonicalising page tables as we go... */
- prev_pc = 0;
- for ( i = 0; i < srec.nr_pfns; i++ )
- {
- this_pc = (i * 100) / srec.nr_pfns;
- if ( (this_pc - prev_pc) >= 5 )
- {
- verbose_printf("\b\b\b\b%3d%%", this_pc);
- prev_pc = this_pc;
- }
-
- mfn = pfn_to_mfn_table[i];
-
- ppage = map_pfn(mfn);
- memcpy(page, ppage, PAGE_SIZE);
- unmap_pfn(ppage);
-
- if ( (pfn_type[i] == L1TAB) || (pfn_type[i] == L2TAB) )
- {
- for ( j = 0;
- j < ((pfn_type[i] == L2TAB) ?
- (HYPERVISOR_VIRT_START >> L2_PAGETABLE_SHIFT) : 1024);
- j++ )
- {
- if ( !(page[j] & _PAGE_PRESENT) ) continue;
- mfn = page[j] >> PAGE_SHIFT;
- if ( !MFN_IS_IN_PSEUDOPHYS_MAP(mfn) )
- {
- ERROR("Frame number in pagetable page is invalid");
- goto out;
- }
- page[j] &= PAGE_SIZE - 1;
- page[j] |= mfn_to_pfn_table[mfn] << PAGE_SHIFT;
- }
- }
-
- if ( !checked_write(gfd, page, PAGE_SIZE) )
- {
- ERROR("Error when writing to state file");
- goto out;
- }
- }
-
- verbose_printf("\b\b\b\b100%%\nMemory saved.\n");
-
- /* Success! */
- rc = 0;
-
- out:
- /* Restart the domain if we had to stop it to save its state. */
- if ( we_stopped_it )
- {
- op.cmd = DOM0_STARTDOMAIN;
- op.u.startdomain.domain = dom;
- (void)do_dom0_op(&op);
- }
-
- gzclose(gfd);
-
- /* On error, make sure the file is deleted. */
- if ( rc != 0 )
- unlink(filename);
-
- return !!rc;
-}
+++ /dev/null
-
-#include "dom0_defs.h"
-#include "mem_defs.h"
-
-static char *argv0 = "internal_domain_sched_domain";
-
-int main(int argc, char **argv)
-{
- dom0_op_t op;
-
- if ( argv[0] != NULL )
- argv0 = argv[0];
-
- if ( argc != 6 )
- {
- fprintf(stderr, "Usage: %s <domain> <mcu_adv> "
- "<warp> <warpl> <warpu>\n", argv0);
- return 1;
- }
-
- op.cmd = DOM0_ADJUSTDOM;
- op.u.adjustdom.domain = atoi(argv[1]);
- op.u.adjustdom.mcu_adv = atol(argv[2]);
- op.u.adjustdom.warp = atol(argv[3]);
- op.u.adjustdom.warpl = atol(argv[4]);
- op.u.adjustdom.warpu = atol(argv[5]);
- if ( do_dom0_op(&op) < 0 )
- return 1;
-
- return 0;
-}
+++ /dev/null
-
-#include "dom0_defs.h"
-#include "mem_defs.h"
-
-static char *argv0 = "internal_domain_sched_global";
-
-int main(int argc, char **argv)
-{
- dom0_op_t op;
-
- if ( argv[0] != NULL )
- argv0 = argv[0];
-
- if ( argc != 2 )
- {
- fprintf(stderr, "Usage: %s <ctxt allowance>\n", argv0);
- return 1;
- }
-
- op.cmd = DOM0_BVTCTL;
- op.u.bvtctl.ctx_allow = atol(argv[1]);
- if ( do_dom0_op(&op) < 0 )
- return 1;
-
- return 0;
-}
+++ /dev/null
-
-#include "dom0_defs.h"
-#include "mem_defs.h"
-
-static char *argv0 = "internal_domain_start";
-
-static int start_domain(int id)
-{
- int err;
- dom0_op_t op;
-
- op.cmd = DOM0_STARTDOMAIN;
- op.u.startdomain.domain = id;
-
- err = do_dom0_op(&op);
-
- return (err < 0) ? -1 : 0;
-}
-
-int main(int argc, char **argv)
-{
- int rc, dom;
-
- if ( argv[0] != NULL )
- argv0 = argv[0];
-
- if ( argc != 2 )
- {
- fprintf(stderr, "Usage: %s <domain-id>\n", argv0);
- return 1;
- }
-
- dom = atoi(argv[1]);
- if ( dom == 0 )
- {
- ERROR("Did you really mean domain 0?");
- return 1;
- }
-
- rc = start_domain(dom);;
-
- return (rc != 0) ? 1 : 0;
-}
+++ /dev/null
-
-#include "dom0_defs.h"
-#include "mem_defs.h"
-
-static char *argv0 = "internal_domain_stop";
-
-static int stop_domain(int id)
-{
- int err;
- dom0_op_t op;
-
- op.cmd = DOM0_STOPDOMAIN;
- op.u.stopdomain.domain = id;
-
- err = do_dom0_op(&op);
-
- return (err < 0) ? -1 : 0;
-}
-
-int main(int argc, char **argv)
-{
- int rc, dom;
-
- if ( argv[0] != NULL )
- argv0 = argv[0];
-
- if ( argc != 2 )
- {
- fprintf(stderr, "Usage: %s <domain-id>\n", argv0);
- return 1;
- }
-
- dom = atoi(argv[1]);
- if ( dom == 0 )
- {
- ERROR("Did you really mean domain 0?");
- return 1;
- }
-
- rc = stop_domain(dom);
-
- return (rc != 0) ? 1 : 0;
-}
+++ /dev/null
-
-#include "dom0_defs.h"
-#include "mem_defs.h"
-
-static char *argv0 = "internal_domain_usage";
-
-int main(int argc, char **argv)
-{
- dom0_op_t op;
- network_op_t netop;
- int i, domain, vifs[32];
-
- if ( argv[0] != NULL )
- argv0 = argv[0];
-
- if ( argc != 2 )
- {
- fprintf(stderr, "Usage: %s <domain-id>\n", argv0);
- return 1;
- }
-
- domain = atol(argv[1]);
-
- op.cmd = DOM0_GETDOMAININFO;
- op.u.getdomaininfo.domain = domain;
- if ( do_dom0_op(&op) < 0 )
- return 1;
-
- printf("cpu%d: %lld\n",
- op.u.getdomaininfo.processor,
- op.u.getdomaininfo.cpu_time);
-
- if ( mlock(vifs, sizeof(vifs)) != 0 )
- {
- PERROR("Could not lock memory for network query buffer");
- return 1;
- }
-
- netop.cmd = NETWORK_OP_VIFQUERY;
- netop.u.vif_query.domain = domain;
- netop.u.vif_query.buf = vifs;
- if ( do_network_op(&netop) < 0 )
- return 1;
-
- for ( i = 1; i <= vifs[0]; i++ )
- {
- netop.cmd = NETWORK_OP_VIFGETINFO;
- netop.u.vif_getinfo.domain = domain;
- netop.u.vif_getinfo.vif = vifs[i];
- if ( do_network_op(&netop) < 0 )
- return 1;
-
- printf("vif%d: sent %lld bytes (%lld packets) "
- "received %lld bytes (%lld packets)\n",
- vifs[i],
- netop.u.vif_getinfo.total_bytes_sent,
- netop.u.vif_getinfo.total_packets_sent,
- netop.u.vif_getinfo.total_bytes_received,
- netop.u.vif_getinfo.total_packets_received);
- }
-
- return 0;
-}
+++ /dev/null
-
-#define _GNU_SOURCE
-#include "dom0_defs.h"
-
-/*
-** Add an extent to a VBD; the VBD must have been created previously.
-*/
-int main(int argc, char *argv[])
-{
- block_io_op_t op;
- unsigned int domain;
- unsigned short vdevice, device;
- int ret;
-
- if ( argc != 6 )
- {
- fprintf(stderr, "Usage: xi_vbd_add <domain> <vdevice> <device>"
- "<start sector> <nr_sectors>\n");
- return 1;
- }
-
-
- domain = atoi(argv[1]);
- device = atoi(argv[2]);
- vdevice = atoi(argv[3]);
-
- op.cmd = BLOCK_IO_OP_VBD_ADD;
- op.u.add_params.domain = domain;
- op.u.add_params.vdevice = vdevice;
-
- op.u.add_params.extent.device = device;
- op.u.add_params.extent.start_sector = atol(argv[4]);
- op.u.add_params.extent.nr_sectors = atol(argv[5]);
-
- ret = do_block_io_op(&op);
-
- if(ret < 0) {
- fprintf(stderr, "error %d attempting to add extent to VBD %04x\n",
- ret, atoi(argv[2]));
- return ret;
- }
-
- return 0;
-}
+++ /dev/null
-
-#define _GNU_SOURCE
-#include "dom0_defs.h"
-
-/*
-** Create a new VBD for a given domain; the VBD can be read-only or
-** read/write, and will be referred to by the relevant domain as 'vdevice'.
-*/
-int main(int argc, char *argv[])
-{
- block_io_op_t op;
- unsigned int domain;
- unsigned short vdevice;
- int ret;
-
- if ( argc != 4 )
- {
- fprintf(stderr, "Usage: xi_vbd_create <domain> <vdevice> <r/rw>\n");
- return 1;
- }
-
- domain = atoi(argv[1]);
- vdevice = atoi(argv[2]);
-
- op.cmd = BLOCK_IO_OP_VBD_CREATE;
- op.u.create_params.domain = domain;
- op.u.create_params.vdevice = vdevice;
- op.u.create_params.mode = 0;
- if ( strchr(argv[3], 'r') )
- op.u.create_params.mode |= VBD_MODE_R;
- if ( strchr(argv[3], 'w') )
- op.u.create_params.mode |= VBD_MODE_W;
-
- ret = do_block_io_op(&op);
-
- if(ret < 0) {
- fprintf(stderr, "error %d attempting to create VBD %04x\n", ret,
- atoi(argv[2]));
- return ret;
- }
-
- return 0;
-}
+++ /dev/null
-
-#define _GNU_SOURCE
-#include "dom0_defs.h"
-
-#define MAX_EXTENTS 32
-#define XEA_SIZE (MAX_EXTENTS * sizeof(xen_extent_t))
-
-int main(int argc, char *argv[])
-{
- block_io_op_t op;
- unsigned int domain;
- unsigned short vdevice;
- xen_extent_t *extents;
- int i, nextents, ret;
-
- if( argc != 3) {
- fprintf(stderr, "Usage: xi_vbd_info domain device\n");
- return 1;
- }
-
- domain = atoi(argv[1]);
- vdevice = atoi(argv[2]);
-
- extents = malloc(XEA_SIZE); // convenience
-
- op.cmd = BLOCK_IO_OP_VBD_INFO;
- op.u.info_params.domain = domain;
- op.u.info_params.vdevice = vdevice;
- op.u.info_params.maxextents = MAX_EXTENTS;
- op.u.info_params.extents = extents;
- op.u.info_params.nextents = 0;
- op.u.info_params.mode = 0;
-
- if(mlock(extents, XEA_SIZE) != 0) {
- PERROR("Could not lock memory for Xen hypercall");
- return -1;
- }
-
- ret = do_block_io_op(&op);
-
- (void)munlock(extents, XEA_SIZE);
-
- if(ret < 0) {
- fprintf(stderr, "error %d attempting to query VBD %04x for dom %d\n",
- ret, vdevice, domain);
- } else {
-
- nextents = op.u.info_params.nextents;
- fprintf(stderr, "Domain %d VBD %04x (mode %s) total of %d extents:\n",
- domain, vdevice, op.u.info_params.mode == 1 ? "read-only"
- : "read/write", nextents);
-
- for(i = 0; i < nextents; i++) {
- fprintf(stderr, "extent %02d: dev %04x start %ld length %ld\n",
- i, extents[i].device, extents[i].start_sector,
- extents[i].nr_sectors);
- }
-
- }
-
-
- return 0;
-}
+++ /dev/null
-
-#define _GNU_SOURCE
-#include "dom0_defs.h"
-
-
-#define MAX_DISKS 32
-#define XDA_SIZE (MAX_DISKS * sizeof(xen_disk_t))
-
-/*
-** List VBDs for oneself or a given domain, or list all VBDs in the system.
-*/
-int main(int argc, char *argv[])
-{
- block_io_op_t op;
- unsigned int domain;
- xen_disk_info_t *xdi;
- int i, ret;
-
- if ( argc > 2 ) {
- fprintf(stderr, "Usage: xi_vbd_list [ <domain> | all ]\n");
- return 1;
- }
-
- /* the default (domain == 0) is to probe for own VBDs */
- domain = 0;
-
- if ( argc == 2) {
- if (!strcmp(argv[1], "all"))
- domain = VBD_PROBE_ALL;
- else
- domain = atoi(argv[1]);
- }
-
- /* allocate some space for the result */
- op.cmd = BLOCK_IO_OP_VBD_PROBE;
- op.u.probe_params.domain = domain;
- op.u.probe_params.xdi.max = MAX_DISKS;
- op.u.probe_params.xdi.disks = malloc(XDA_SIZE);
- op.u.probe_params.xdi.count = 0;
-
- xdi = &op.u.probe_params.xdi; // convenience
-
- if(mlock(xdi->disks, XDA_SIZE) != 0 ) {
- PERROR("Could not lock memory for Xen hypercall");
- return -1;
- }
-
- ret = do_block_io_op(&op);
-
- (void)munlock(xdi->disks, XDA_SIZE);
-
-
- if(ret < 0) {
- fprintf(stderr, "error %d attempting to probe VBDs\n", ret);
- } else {
- for(i = 0; i < xdi->count; i++)
- fprintf(stderr,
- "Domain %02d %cBD: [R/%c] device %04x capacity %ldkB\n",
- xdi->disks[i].domain, XD_VIRTUAL(xdi->disks[i].info) ?
- 'V' : 'P', XD_READONLY(xdi->disks[i].info) ? 'O' : 'W',
- xdi->disks[i].device, xdi->disks[i].capacity >> 1);
- }
-
- return ret;
-}
+++ /dev/null
-
-#include "dom0_defs.h"
-#include "mem_defs.h"
-
-static char *argv0 = "internal_domain_vif_params";
-
-int main(int argc, char **argv)
-{
- network_op_t netop;
- int domain, vif;
- unsigned long credit_bytes, credit_usec;
-
- if ( argv[0] != NULL )
- argv0 = argv[0];
-
- if ( (argc != 3) && (argc != 5) )
- {
- fprintf(stderr, "Usage: %s <domain-id> <vif-id> "
- "[<credit-bytes> <credit-usec>]\n", argv0);
- fprintf(stderr, "Specify <credit usec> == 0 to disable scheduling\n");
- return 1;
- }
-
- domain = atol(argv[1]);
- vif = atol(argv[2]);
-
- if ( argc == 5 )
- {
- credit_bytes = atol(argv[3]);
- credit_usec = atol(argv[4]);
-
- netop.cmd = NETWORK_OP_VIFSETPARAMS;
- netop.u.vif_setparams.domain = domain;
- netop.u.vif_setparams.vif = vif;
- netop.u.vif_setparams.credit_bytes = credit_bytes;
- netop.u.vif_setparams.credit_usec = credit_usec;
- if ( do_network_op(&netop) < 0 )
- return 1;
-
- if ( credit_usec != 0 )
- {
- printf("Set scheduling to %lu bytes every"
- " %lu usecs (%2.2f Mbps)\n",
- credit_bytes, credit_usec,
- ((float)credit_bytes/(1024.0*1024.0/8.0)) /
- ((float)credit_usec/1000000.0));
- }
- else
- {
- printf("Disabled rate limiting for vif\n");
- }
- }
- else
- {
- netop.cmd = NETWORK_OP_VIFGETINFO;
- netop.u.vif_getinfo.domain = domain;
- netop.u.vif_getinfo.vif = vif;
- if ( do_network_op(&netop) < 0 )
- return 1;
-
- printf("%lld bytes transmitted\n"
- "%lld packets transmitted\n"
- "%lld bytes received\n"
- "%lld packets received\n",
- netop.u.vif_getinfo.total_bytes_sent,
- netop.u.vif_getinfo.total_packets_sent,
- netop.u.vif_getinfo.total_bytes_received,
- netop.u.vif_getinfo.total_packets_received);
-
- if ( netop.u.vif_getinfo.credit_usec != 0 )
- {
- printf("Scheduling: %lu bytes every %lu usecs (%2.2f Mbps)\n",
- netop.u.vif_getinfo.credit_bytes,
- netop.u.vif_getinfo.credit_usec,
- ((float)netop.u.vif_getinfo.credit_bytes/(1024.0*1024.0/8.0)) /
- ((float)netop.u.vif_getinfo.credit_usec/1000000.0));
- }
- else
- {
- printf("Scheduling: no rate limit\n");
- }
- }
-
- return 0;
-}
+++ /dev/null
-#!/bin/bash
-#
-# vifinit
-#
-# This is a silly little script to dump a couple of simple rules down to
-# the hypervisor to assign a full static IP to a given virtual interface.
-#
-# Usage is:
-#
-# vifinit [vif dom] [vif idx] [dotted decimal ip address]
-#
-if [ $# -ne 3 ] ;
-then
- echo "usage: $0 <domain_id> <vid_ifx> <dotted_decimal_ip_address>"
- exit
-fi
-
-#outbound rule:
-echo $3 | grep -q "^169\\.254\\."
-if [ $? -eq 0 ];
-then
- # If this is a link local address, send to dom0
- echo "ADD ACCEPT srcaddr=$3 srcaddrmask=255.255.255.255 srcdom=$1 srcidx=$2 dstdom=0 dstidx=0 proto=any" > /proc/xeno/vfr
-else
- # If this is not, send to wire
- echo "ADD ACCEPT srcaddr=$3 srcaddrmask=255.255.255.255 srcdom=$1 srcidx=$2 dst=PHYS proto=any" > /proc/xeno/vfr
-fi
-
-#inbound rule:
-echo "ADD ACCEPT dstaddr=$3 dstaddrmask=255.255.255.255 src=ANY dstdom=$1 dstidx=$2 proto=any" > /proc/xeno/vfr
-
-#----] done.
-
CC = gcc
CFLAGS = -Wall -O3
-EXTRA_INC = -I../../xen/include -I../../xenolinux-sparse/include -I../internal
+EXTRA_INC = -I../../xen/include -I../../xenolinux-sparse/include -I../xc/lib
HDRS = $(wildcard *.h)
SRCS = $(wildcard *.c)
OBJS = $(patsubst %.c,%.o,$(SRCS))
-TARGETS = xen_read_console xen_cpuperf xen_refresh_dev
+TARGETS = xen_read_console xen_refresh_dev xen_cpuperf
INSTALL = $(TARGETS) xen-mkdevnodes xen_nat_enable xen-clone
+INSTALL += xi_createlinuxdom.py xi_destroydom.py xi_listdoms.py
+INSTALL += xi_stopdom.py
all: $(TARGETS)
$(MAKE) -C miniterm
chmod 755 ../../../install/bin/xen-mkdevnodes
chmod 755 ../../../install/bin/xen_nat_enable
chmod 755 ../../../install/bin/xen-clone
+ chmod 755 ../../../install/bin/xi_createlinuxdom.py
+ chmod 755 ../../../install/bin/xi_destroydom.py
+ chmod 755 ../../../install/bin/xi_listdoms.py
+ chmod 755 ../../../install/bin/xi_stopdom.py
$(MAKE) -C miniterm install
clean:
#include <string.h>
#include "p4perf.h"
-#include "dom0_defs.h"
+#include "libxc_private.h"
-void dom0_wrmsr( int cpu_mask, int msr, unsigned int low, unsigned int high )
+void dom0_wrmsr( int privfd,
+ int cpu_mask,
+ int msr,
+ unsigned int low,
+ unsigned int high )
{
- dom0_op_t op;
- op.cmd = DOM0_MSR;
- op.u.msr.write = 1;
- op.u.msr.msr = msr;
- op.u.msr.cpu_mask = cpu_mask;
- op.u.msr.in1 = low;
- op.u.msr.in2 = high;
- do_dom0_op(&op);
+ dom0_op_t op;
+ op.cmd = DOM0_MSR;
+ op.u.msr.write = 1;
+ op.u.msr.msr = msr;
+ op.u.msr.cpu_mask = cpu_mask;
+ op.u.msr.in1 = low;
+ op.u.msr.in2 = high;
+ do_dom0_op(privfd, &op);
}
-unsigned long long dom0_rdmsr( int cpu_mask, int msr )
+unsigned long long dom0_rdmsr( int privfd,
+ int cpu_mask,
+ int msr )
{
- dom0_op_t op;
- op.cmd = DOM0_MSR;
- op.u.msr.write = 0;
- op.u.msr.msr = msr;
- op.u.msr.cpu_mask = cpu_mask;
- do_dom0_op(&op);
- return (((unsigned long long)op.u.msr.out2)<<32) | op.u.msr.out1 ;
+ dom0_op_t op;
+ op.cmd = DOM0_MSR;
+ op.u.msr.write = 0;
+ op.u.msr.msr = msr;
+ op.u.msr.cpu_mask = cpu_mask;
+ do_dom0_op(privfd, &op);
+ return (((unsigned long long)op.u.msr.out2)<<32) | op.u.msr.out1 ;
}
struct macros {
int debug = 0;
unsigned long pebs = 0, pebs_vert = 0;
int pebs_x = 0, pebs_vert_x = 0;
- int read = 0;
+ int read = 0, privfd;
while ((c = getopt(argc, argv, "dc:t:e:m:T:E:C:P:V:r")) != -1) {
switch((char)c) {
debug = 1;
break;
case 'c':
- {
+ {
int cpu = atoi(optarg);
cpu_mask = (cpu == -1)?(~0):(1<<cpu);
break;
- }
+ }
case 't': // ESCR thread bits
t = atoi(optarg);
break;
}
}
+ if ( (privfd = open("/proc/xeno/privcmd", O_RDWR)) == -1 )
+ {
+ fprintf(stderr, "Could not open privileged Xen control interface.\n");
+ exit(1);
+ }
+
if (read) {
while((cpu_mask&1)) {
- int i;
- for (i=0x300;i<0x312;i++)
- {
- printf("%010llx ",dom0_rdmsr( cpu_mask, i ) );
- }
- printf("\n");
- cpu_mask>>=1;
+ int i;
+ for (i=0x300;i<0x312;i++)
+ {
+ printf("%010llx ",dom0_rdmsr( privfd, cpu_mask, i ) );
+ }
+ printf("\n");
+ cpu_mask>>=1;
}
exit(1);
}
MSR_P4_PEBS_MATRIX_VERT, pebs_vert);
}
- dom0_wrmsr( cpu_mask, escr->msr_addr, escr_val, 0 );
- dom0_wrmsr( cpu_mask, cccr->msr_addr, cccr_val, 0 );
+ dom0_wrmsr( privfd, cpu_mask, escr->msr_addr, escr_val, 0 );
+ dom0_wrmsr( privfd, cpu_mask, cccr->msr_addr, cccr_val, 0 );
if (pebs_x)
- dom0_wrmsr( cpu_mask, MSR_P4_PEBS_ENABLE, pebs, 0 );
+ dom0_wrmsr( privfd, cpu_mask, MSR_P4_PEBS_ENABLE, pebs, 0 );
if (pebs_vert_x)
- dom0_wrmsr( cpu_mask, MSR_P4_PEBS_MATRIX_VERT, pebs_vert, 0 );
+ dom0_wrmsr( privfd, cpu_mask, MSR_P4_PEBS_MATRIX_VERT, pebs_vert, 0 );
return 0;
}
--- /dev/null
+#!/usr/bin/python
+
+#
+# Example script for creating and building a new Linux guest OS for Xen.
+#
+
+import Xc, XenoUtil, sys, os
+
+# Variable declaration. Set these up properly later on, as needed.
+nfsserv = nfspath = root_partn = usr_partn = ""
+
+# STEP 1. Specify kernel image file.
+image = "FULL_PATH_TO_IMAGE"
+
+# STEP 2. Specify IP address, netmask and gateway for the new domain.
+ipaddr = "ADDRESS"
+netmask = XenoUtil.get_current_ipmask()
+gateway = XenoUtil.get_current_ipgw()
+
+# STEP 3. Specify NFS server and path to rootfs (only needed for network boot)
+nfsserv = "ADDRESS"
+nfspath = "FULL_PATH_TO_ROOT_DIR"
+
+# STEP 4. Specify root (and possibly /usr) on local disc (if not NFS booting)
+#root_partn = "/dev/sda2"
+#usr_partn = "/dev/sda6"
+
+# STEP 5. Check that the following cmdline setup is to your taste.
+cmdline = "ip="+ipaddr+":"+nfsserv+":"+gateway+":"+netmask+"::eth0:off"
+if root_partn:
+ # Boot from local disc. May specify a separate /usr.
+ cmdline = cmdline + " root="+root_partn+" ro"
+ if usr_partn:
+ " usr="+usr_partn
+elif nfsserv:
+ # NFS boot
+ cmdline = cmdline + " root=/dev/nfs"
+ cmdline = cmdline + " nfsroot="+nfspath
+
+if root_partn:
+ root_info = XenoUtil.lookup_blkdev_partn_info(root_partn)
+ if not root_info:
+ print "Could not obtain info on partition '" + root_partn + "'"
+ sys.exit()
+
+if usr_partn:
+ usr_info = XenoUtil.lookup_blkdev_partn_info(usr_partn)
+ if not usr_info:
+ print "Could not obtain info on partition '" + usr_partn + "'"
+ sys.exit()
+
+if not os.path.isfile( image ):
+ print "Image file '" + image + "' does not exist"
+ sys.exit()
+
+xc = Xc.new()
+
+id = xc.domain_create()
+if id <= 0:
+ print "Error creating domain"
+ sys.exit()
+
+if xc.linux_build( dom=id, image=image, cmdline=cmdline ):
+ print "Error building Linux guest OS"
+ xc.domain_destroy ( dom=id )
+ sys.exit()
+
+if root_partn:
+ if xc.vbd_create( dom=id, vbd=root_info[0], writeable=1 ):
+ print "Error creating root VBD"
+ xc.domain_destroy ( dom=id )
+ sys.exit()
+ if xc.vbd_add_extent( dom=id,
+ vbd=root_info[0],
+ device=root_info[1],
+ start_sector=root_info[2],
+ nr_sectors=root_info[3] ):
+ print "Error populating root VBD"
+ xc.domain_destroy ( dom=id )
+ sys.exit()
+
+if usr_partn:
+ if xc.vbd_create( dom=id, vbd=usr_info[0], writeable=0 ):
+ print "Error creating usr VBD"
+ xc.domain_destroy ( dom=id )
+ sys.exit()
+ if xc.vbd_add_extent( dom=id,
+ vbd=usr_info[0],
+ device=usr_info[1],
+ start_sector=usr_info[2],
+ nr_sectors=usr_info[3] ):
+ print "Error populating usr VBD"
+ xc.domain_destroy ( dom=id )
+ sys.exit()
+
+XenoUtil.setup_vfr_rules_for_vif( id, 0, ipaddr )
+
+if xc.domain_start( dom=id ):
+ print "Error starting domain"
+ xc.domain_destroy ( dom=id )
+ sys.exit()
--- /dev/null
+#!/usr/bin/python
+
+#
+# Destroy specified domain.
+#
+
+import Xc, sys, re
+
+xc = Xc.new()
+
+if len(sys.argv) < 2:
+ print "Specify a domain identifier"
+ sys.exit()
+
+if (len(sys.argv) > 2) and re.match( 'force', sys.argv[2] ):
+ xc.domain_destroy( dom=int(sys.argv[1]), force=0 )
+else:
+ xc.domain_destroy( dom=int(sys.argv[1]), force=1 )
--- /dev/null
+#!/usr/bin/python
+
+#
+# List info on all domains.
+#
+
+import Xc, sys
+xc = Xc.new()
+print xc.domain_getinfo()
+
--- /dev/null
+#!/usr/bin/python
+
+#
+# Stop execution of specified domain.
+#
+
+import Xc, sys, re
+
+xc = Xc.new()
+
+if len(sys.argv) != 2:
+ print "Specify a domain identifier"
+ sys.exit()
+
+xc.domain_stop( dom=int(sys.argv[1]) )
char *name = "(anon)";
int ret;
- static char *kwd_list[] = { "mem_kb", "name" };
+ static char *kwd_list[] = { "mem_kb", "name", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|is", kwd_list,
&mem_kb, &name) )
unsigned int dom;
int ret;
- static char *kwd_list[] = { "dom" };
+ static char *kwd_list[] = { "dom", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
return NULL;
unsigned int dom;
int ret;
- static char *kwd_list[] = { "dom" };
+ static char *kwd_list[] = { "dom", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
return NULL;
return PyInt_FromLong(ret);
}
+static PyObject *pyxc_domain_destroy(PyObject *self,
+ PyObject *args,
+ PyObject *kwds)
+{
+ XcObject *xc = (XcObject *)self;
+
+ unsigned int dom;
+ int force = 0, ret;
+
+ static char *kwd_list[] = { "dom", "force", NULL };
+
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
+ &dom, &force) )
+ return NULL;
+
+ ret = xc_domain_destroy(xc->xc_handle, dom, force);
+
+ return PyInt_FromLong(ret);
+}
+
static PyObject *pyxc_domain_getinfo(PyObject *self,
PyObject *args,
PyObject *kwds)
int nr_doms, i;
xc_dominfo_t *info;
- static char *kwd_list[] = { "first_dom", "max_doms" };
+ static char *kwd_list[] = { "first_dom", "max_doms", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwd_list,
&first_dom, &max_doms) )
char *state_file;
int progress = 1, ret;
- static char *kwd_list[] = { "dom", "state_file", "progress" };
+ static char *kwd_list[] = { "dom", "state_file", "progress", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is|i", kwd_list,
&dom, &state_file, &progress) )
char *state_file;
int progress = 1, ret;
- static char *kwd_list[] = { "state_file", "progress" };
+ static char *kwd_list[] = { "state_file", "progress", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "s|i", kwd_list,
&state_file, &progress) )
char *image, *ramdisk = NULL, *cmdline = "";
int ret;
- static char *kwd_list[] = { "dom", "image", "ramdisk", "cmdline" };
+ static char *kwd_list[] = { "dom", "image", "ramdisk", "cmdline", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is|ss", kwd_list,
&dom, &image, &ramdisk, &cmdline) )
unsigned long ctx_allow;
int ret;
- static char *kwd_list[] = { "ctx_allow" };
+ static char *kwd_list[] = { "ctx_allow", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "l", kwd_list, &ctx_allow) )
return NULL;
unsigned long mcuadv, warp, warpl, warpu;
int ret;
- static char *kwd_list[] = { "dom", "mcuadv", "warp", "warpl", "warpu" };
+ static char *kwd_list[] = { "dom", "mcuadv", "warp", "warpl",
+ "warpu", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "illll", kwd_list,
&dom, &mcuadv, &warp, &warpl, &warpu) )
xc_vif_sched_params_t sched = { 0, 0 };
int ret;
- static char *kwd_list[] = { "dom", "vif", "credit_bytes", "credit_usecs" };
+ static char *kwd_list[] = { "dom", "vif", "credit_bytes",
+ "credit_usecs", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii|ll", kwd_list,
&dom, &vif,
xc_vif_sched_params_t sched;
int ret;
- static char *kwd_list[] = { "dom", "vif" };
+ static char *kwd_list[] = { "dom", "vif", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
&dom, &vif) )
xc_vif_stats_t stats;
int ret;
- static char *kwd_list[] = { "dom", "vif" };
+ static char *kwd_list[] = { "dom", "vif", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
&dom, &vif) )
unsigned int dom, vbd;
int writeable, ret;
- static char *kwd_list[] = { "dom", "vbd", "writeable" };
+ static char *kwd_list[] = { "dom", "vbd", "writeable", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iii", kwd_list,
&dom, &vbd, &writeable) )
unsigned int dom, vbd;
int ret;
- static char *kwd_list[] = { "dom", "vbd" };
+ static char *kwd_list[] = { "dom", "vbd", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
&dom, &vbd) )
int ret;
static char *kwd_list[] = { "dom", "vbd", "device",
- "start_sector", "nr_sectors" };
+ "start_sector", "nr_sectors", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiill", kwd_list,
&dom, &vbd, &device,
int ret;
static char *kwd_list[] = { "dom", "vbd", "device",
- "start_sector", "nr_sectors" };
+ "start_sector", "nr_sectors", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiill", kwd_list,
&dom, &vbd, &device,
xc_vbd_t *info;
int nr_vbds, i;
- static char *kwd_list[] = { "dom", "max_vbds" };
+ static char *kwd_list[] = { "dom", "max_vbds", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwd_list,
&dom, &max_vbds) )
char str[32768];
int ret;
- static char *kwd_list[] = { "clear" };
+ static char *kwd_list[] = { "clear", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwd_list, &clear) )
return NULL;
" dom [int]: Identifier of domain to be stopped.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
+ { "domain_destroy",
+ (PyCFunction)pyxc_domain_destroy,
+ METH_VARARGS | METH_KEYWORDS, "\n"
+ "Destroy a domain.\n"
+ " dom [int]: Identifier of domain to be destroyed.\n"
+ " force [int, 0]: Bool - force immediate destruction?\n\n"
+ "Returns: [int] 0 on success; -1 on error.\n" },
+
{ "domain_getinfo",
(PyCFunction)pyxc_domain_getinfo,
METH_VARARGS | METH_KEYWORDS, "\n"
O_TARGET := blk.o
-obj-y := xl_block.o xl_vbd.o info.o
+obj-y := xl_block.o xl_vbd.o
include $(TOPDIR)/Rules.make
+++ /dev/null
-
-#include "xl_block.h"
-#include <linux/blk.h>
-#include <linux/cdrom.h>
-#include <linux/genhd.h>
-#include <linux/seq_file.h>
-#include <asm/xeno_proc.h>
-
-static struct proc_dir_entry *info_pde;
-
-static void *info_start(struct seq_file *s, loff_t *ppos)
-{
- struct gendisk *gp;
- loff_t pos = *ppos;
- int major;
-
- if ( pos == 0 )
- seq_puts(s, "major minor start_sector num_sectors name\n\n");
-
- for ( major = 0; major < MAX_BLKDEV; major++ )
- {
- if ( (gp = get_gendisk(MKDEV(major, 0))) != 0 )
- if ( !pos-- )
- return gp;
- }
-
- return NULL;
-}
-
-static void *info_next(struct seq_file *s, void *v, loff_t *ppos)
-{
- ++*ppos;
- return info_start(s, ppos);
-}
-
-static void info_stop(struct seq_file *s, void *v)
-{
-}
-
-static int info_show(struct seq_file *s, void *v)
-{
- struct gendisk *gp = v;
- char buf[64];
- int n, disk;
-
- for ( n = 0; n < (gp->nr_real << gp->minor_shift); n++ )
- {
- disk = n >> gp->minor_shift;
- if ( gp->part[n].nr_sects != 0 )
- {
- seq_printf(s, "%5d %5d %12ld %12ld %s\n",
- gp->major, n,
- gp->part[n].start_sect,
- gp->part[n].nr_sects,
- disk_name(gp, n, buf));
- }
- else if ( ((disk << gp->minor_shift) == n) &&
- ((((xl_disk_t *)gp->real_devices)[disk].capacity) != 0) )
- {
- seq_printf(s, "%5d %5d %12d %12ld %s\n",
- gp->major, n, 0,
- ((xl_disk_t *)gp->real_devices)[disk].capacity,
- disk_name(gp, n, buf));
- }
- }
-
- return 0;
-}
-
-static struct seq_operations info_op = {
- .start = info_start,
- .next = info_next,
- .stop = info_stop,
- .show = info_show,
-};
-
-static int info_open(struct inode *inode, struct file *file)
-{
- return seq_open(file, &info_op);
-}
-
-static struct file_operations proc_info_operations =
-{
- open: info_open,
- read: seq_read,
- llseek: seq_lseek,
- release: seq_release,
-};
-
-int __init info_init(void)
-{
- info_pde = create_xeno_proc_entry("blkdev_info", 0444);
- if ( info_pde == NULL )
- panic ("Couldn't create /proc/xeno/blkdev_info");
-
- info_pde->data = NULL;
- info_pde->proc_fops = &proc_info_operations;
- info_pde->owner = THIS_MODULE;
-
- return 0;
-}
-
-static void __exit info_exit(void)
-{
- if ( info_pde == NULL ) return;
- remove_xeno_proc_entry("blkdev_info");
- info_pde = NULL;
-}
-
-module_init(info_init);
-module_exit(info_exit);